Skip to content

Latest commit

 

History

History
337 lines (299 loc) · 21.3 KB

README.md

File metadata and controls

337 lines (299 loc) · 21.3 KB

Resources

misc/todo

https://github.com/nix-community/home-manager https://typeof.net/Iosevka/ https://github.com/DieracDelta/flakes/blob/flakes/.github/workflows/cachix.yml https://github.com/nmattia/niv https://github.com/ryantm/agenix https://github.com/nix-community/lorri MOZ_USE_XINPUT2=1 for Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1438107) MOZ_ENABLE_WAYLAND

enable fstrim: https://www.reddit.com/r/NixOS/comments/rbzhb1/if_you_have_a_ssd_dont_forget_to_enable_fstrim/

use nixos-hardware flake enable nix sandbox on macOS? enable flakes enable content-addressed Nix: https://discourse.nixos.org/t/content-addressed-nix-call-for-testers/12881 use unstable channel remap caps lock: https://unix.stackexchange.com/questions/377600/in-nixos-how-to-remap-caps-lock-to-control

LICENSE

look into/read:

can't find an archived copy of this :-(

IFD: https://nixos.wiki/wiki/Import_From_Derivation

install lorri look into direnv vscode: https://marketplace.visualstudio.com/items?itemName=Rubymaniac.vscode-direnv

nix gc option (for lorri, mostly) that only frees things that haven't been used in 1week+, etc.

  • this'd be nice for nix-shell/lorri things; any projects that hasn't been entered in, say, a week loses its gc-root
  • somewhat relevant: NixOS/nix#2793
  • easiest way to achieve this might be to wrap lorri (or whatever direnv plugin we use)'s use_nix function with our own thing that records, somewhere, when nix-shell based gcroots were last "entered"
    • lorri doesn't seem to even register a direnv lib bash file that overrides use_nix(); instead it seems to prefer emitting .envrc files with eval "$(lorri direnv)" (grep for cat .direnv on this post)
    • so, we should be able to register our own direnv lib file like this that records out metadata somewhere and then shells out to eval "$(lorri direnv)"
      • note the writeShellCheckedShareLib!
    • then, we can also create a separate service that runs every so often and checks the metadata we record and uses it to unregister gc roots that were registered from .direnv activations that haven't been re-entered in

install https://github.com/lf-/nix-doc with plugin stuff

nix gc enable (not on battery power) zfs snapshot, cleanup, etc. (not on battery power, etc.; or reduced freq for snapshotting on battery power)

.cargo/config that's generated with:

  • target.<triple>.linker = some wrapper that shells out to ld.lld or mold rustflags = some wrapper that shells out to ld.lld or mold (i.e. ["-C', "link-arg=fuse-ld=lld-wrapper"]?)
    • note: linker only seems to be available for target.<triple> and not target.<cfg()>; rustflags is available for both and can work when -C link-arg= can be used to specify the desired linker
      • for us, specifying mold using -C link-arg=fuse-ld=lld is tricky; we'd need to replace the ld.lld binary with a wrapper, etc.
    • we don't want to use mold for release builds
      • unfortunately there doesn't seem to be a way to do this in .cargo/config; we can't set rustflags conditionally based on the release profile (see this) and the release profile doesn't include a rustflags key or a linker key (see this)
      • best I can come up with is to create a wrapper that checks the paths for "release"/"debug"/"bench", etc. and shells out to mold/lld as appropriate
  • rustc-wrapper = sccache

update rust-template with nix stuff (.envrc, flake.nix, flake.lock, shell.nix with flake-compat, etc.; gonna leave nix out of the CI for now I think) (also action-rs rust cache, maybe; rust-version in cargo.toml, 2021 edition, rustfmt updates, .toml for rustfmt and clippy, clippy updates, remove lint list dump, use include_str! for readme, etc.)

https://www.youtube.com/watch?v=XZ9nPZbaYfE

misc notes

nix-env uses nix (build and store and friends) to make nix profiles (set ~/.nix-profile, and to make symlink forests in the form of profiles in the nix store)

  • takes a bunch of derivations and gives you a profile
  • nix-env then sticks this profile in your home directory with the appropriate glue (generations in /nix/var/profiles/per-user/..., hooks (as part of nixos? it's unclear who puts these in the default bashrc) to have $XDG_DATA_DIRS point to the generated folders, etc) nixpkgs:
  • repository of packages
  • uses stdenv, lib, callPackage idiom, etc
  • config and override system
  • overlays as the mechanism to layer nixos:
  • set of modules
  • also makes a derivation (out of modules which can in turn pull in nixpkgs) that's then used to make a profile, just like nix-env
    • but this profile has different stuff, the generations go in /nix/var/nix/profiles/system-* (I think), managed by nixos-* commands, symlinked to /run/current-system, etc.
    • the nixos-* commands handle all of ^ plus doing things like restarting systemd service on switch and such home-manager:
  • also generates a nix profile but from a config file (unlike nix-env which modifies the "current" profile)
  • can "manage" files that aren't in the nix store; i.e. doesn't just stick everything in the ~/.nix-profile (?)
  • cross platform, not tied to nixos nix-darwin:
  • like nixos but for macOS; manages system settings too (no idea how though)

build does:

  • instantiate (runs the evaluator to produce derivations)
  • realisations ("builds" the derivations)
    • these interact with the nix store
    • nix-daemon does this

build-vm gives you a handy qemu runner script (doesn't even need a bootloader)

structure

  • lib: nix helper utils, if the need arises
  • machines: ...
  • modules: my own nixos modules
  • mixins: config things for other things. some call these "roles" or services or w/e
    • darwin: nix-darwin module things (these are really just modules too)
    • home-manager (also just modules)
      • have an all or a default that is system aware or something
    • nixos: nixos module config stuff (also just modules)
    • overlays
      • each are overlay fns (i.e. prev, final: ...)
      • have an all
    • users
  • packages: my own nixpkgs
  • resources: secrets, config files, other supporting Things. mixins and machines can make reference to these freely, no one else.

top-level (flake.nix) should import the stuff in modules as well as external modules see: https://github.com/frogamic/nix-machines/blob/6e2bf36b60fd288476a83b7e7babebfc012c3f6e/flake.nix#L16-L44

expose nixosModule, nixosModules, pkgs, lib, overlay, and overlays in default.nix in the style of: https://github.com/frogamic/nix-machines/blob/main/default.nix

flake exports:

  • nixosConfigurations: auto-populate the list from ./machines, etc
  • packages: the things in packages
  • apps: apps to export? i.e. things with their configs builtin? can just reference config stuff in resources I guess?
  • overlay: all of the overlays
  • overlays: the things in overlays, a list?
  • nixosModule: all of the modules
  • nixosModules: things in modules, an attrset?
  • checks: check that builds all the stuff? vm images? subs in fake secrets? this is what CI should run, ideally
  • defaultApp: runs the vm produces by machines/vm?

TODO: register this repo as a flake registry (just r)

TODO: plain-text diffing for (r)age? (the way sops -d is used as a git diff filter) agenix with a working nix-darwin module: https://github.com/montchr/agenix/compare/darwin-support...rtimush:agenix:darwin-support

TODO: running nixos modules outside of home-manager: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/testing/service-runner.nix

TODO: a nixos-module service to home-manager module adapter! this is probably a good starting point: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/testing/service-runner.nix

TODO: why isn't there a service abstraction in home-manager that papers over systemd/launchctl? https://discourse.nixos.org/t/services-on-macos/9095/4 nix-community/home-manager#91 nix-community/home-manager#91 (comment)

TODO: https://discourse.nixos.org/t/franken-script-to-generate-nixos-options-docs-with-custom-modules/1674

names for later

lich (undead, pulsar) fafnir castor deneb acrux (system of 6) spica (system of 2) castor (system of 6) aniara meissa mago mira procyon

dimidium lete haik (water) eyeke dulcinea, quijote, sancho, rocinante (from don quixote, around cervantes (mu arae)) around lich:

  • poltergist
  • phobetor
  • dragur isagel (character from aniara) tondra (nap, sleepy)

TODO: figure out how to pass --backup to home-manager running in the flake