News for hackers. Stuff that matters.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by wingmanjd on Monday January 23, 2023 @11:42AM (#34491184)
Do you symlink your config repo to /etc/nixos or something else? So far, I've just been rsyncing my config repo folder after I modify it.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by Filligree on Monday January 23, 2023 @11:54AM (#34491433)
I use an update script that overrides that location to $(pwd), and also uses nvd to print a package diff for the update. Among a few other niceties. With flakes, that's a regular nixos-rebuild flag; otherwise it's an envvar.

/etc/nixos is just the default, there's a number of ways to set your own path. One of the simplest might be to put "import /home/wherever" as the sole contents of configuration.nix.

Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by cole-h on Monday January 23, 2023 @12:01PM (#34491564)
That sounds like a nice little workflow; I might have to incorporate something like that with `nvd`...

Though, it should be said that `import /home/wherever` might not work if you switch to / use flakes, as that is likely outside of the flake's git repo (and thus impure).

Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by kevincox on Monday January 23, 2023 @11:52AM (#34491386)
Yeah, I symlink `/etc/nixos/configuration.nix` to my git repo. (I do keep a `hardware-configuration.nix` which isn't version controlled. I probably should add version-control at some point but for now it is simple enough to copy around and maybe make some minor tweaks).
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by grhmc on Monday January 23, 2023 @11:48AM (#34491310)
You can actually put your NixOS config anywhere. Assuming you're not using flakes, `nixos-rebuild` finds the config through NIX_PATH:

grahamc@scruffy:~/ > echo $NIX_PATH

nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels

you can change the `nixos-config` value to point to somewhere else, or call it like this:`nixos-rebuild -I nixos-config=./configuration.nix`

Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by cole-h on Monday January 23, 2023 @11:50AM (#34491344)
I don't; my config lives in ~/flake, and I run `nixos-rebuild ... --flake ~/flake` whenever I update it.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by choward on Monday January 23, 2023 @02:01PM (#34493343)
You don't have to specify the nixosConfiguration name (e.g ~/flake#my-configuration)? Do you just name it "default" or something for that to work? I've never tried that.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by Macha on Monday January 23, 2023 @02:12PM (#34493494)
You name it the same as your current system's hostname.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by choward on Monday January 23, 2023 @04:08PM (#34495045)
Oh, I had no idea. I was actually already doing that. Guess I was just being extra verbose on the command line.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by cole-h on Monday January 23, 2023 @02:46PM (#34493939)
Exactly as Macha said, if you name the attribute `nixosConfiguration.<hostname>`, `nixos-rebuild` will look for that attribute implicitly; you can still specify another configuration if you're e.g. in a VM or a live image.
Re:Zero to Nix, an unofficial, opinionated, gentle introduct... by mfsch on Monday January 23, 2023 @06:17PM (#34496494)
You can also use `git init --separate-git-dir=~/something /etc/nixos` to keep the git data in your user directory while the config remains in the default location. I like this solution because it keeps the stuff I want to do as root (configuring the system) separate from what I want to do as regular user (tracking changes of the configuration).