You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Related to #719 because nh relies on nvd and nom to improve UX. Read nh's README for a better elevator pitch...
A FLAKE=/home/user/nix-configuration is set to specify where the NixOS and home-manager configuration lives. nh picks this up and looks for configuration there, so you'll never need to manually specify where your config lives. This is useful for people who keep their nix dotfiles version-controlled in a flake.
Which operating systems are supported by this tool?
What should Topgrade do to figure out if the tool needs to be invoked?
Check wether $FLAKE exists, is a directory and contains a flake.nix. Then we know that a NixOS and/or home-manager configuration should live in that directory.
To check wether a NixOS configuration is present, you could parse the output of nix eval --json $FLAKE#nixosConfigurations --apply builtins.attrNames and look for $(hostname).
Example output of above command:
["tom-laptop", "tom-pc"]
To check wether a home-manager configuration is present, you could parse the output of nix eval --json $FLAKE#homeConfigurations --apply builtins.attrNames and look for an entry in the form of $(whoami)@$(hostname) or just $(whoami).
Example output of above command:
["tomvd@aurora", "tomvd@tom-pc", "alice"]
Which exact commands should Topgrade run?
When "$FLAKE" is a valid flake: nix --experimental-features "nix-command flakes" flake update --flake $FLAKE;
When we've found a NixOS configuration: nh os switch;
When we've found a home-manager configuration: nh home switch.
Does it have a --dry-run option? i.e., print what should be done and exit
nix flake update does NOT have --dry-run, but nh has --dry.
Does it need the user to confirm the execution? And does it provide a --yes option to skip this step?
nix flake update never asks for user input;
nh os switch never asks by itself unless you specify --ask, but requires a sudo password to actually finish the update;
nh home switch never asks for confirmation unless --ask is specified.
More information
I know how to test this feature if someone were to implement it. I am willing to do it myself though.
NOTE: where I specified any nix command it is a good idea to use nix --experimental-features "nix-command flakes" as in some systems this isn't enabled yet and nix will refuse to do anything with flakes when it isn't set.
The text was updated successfully, but these errors were encountered:
I want to suggest a new step
Which tool is this about? Where is its repository?
nh
, the nix helper, used for updating nixos and home-manager through flakesGitHub: https://github.com/viperML/nh
Found in nixpkgs at: https://github.com/NixOS/nixpkgs/blob/nixos-24.11/pkgs/by-name/nh/nh/package.nix
Related to #719 because
nh
relies onnvd
andnom
to improve UX. Readnh
's README for a better elevator pitch...A
FLAKE=/home/user/nix-configuration
is set to specify where the NixOS and home-manager configuration lives.nh
picks this up and looks for configuration there, so you'll never need to manually specify where your config lives. This is useful for people who keep their nix dotfiles version-controlled in a flake.Which operating systems are supported by this tool?
They only target NixOS-supported systems.
In their
flake.nix
they specify:What should Topgrade do to figure out if the tool needs to be invoked?
Check wether
$FLAKE
exists, is a directory and contains aflake.nix
. Then we know that a NixOS and/or home-manager configuration should live in that directory.To check wether a NixOS configuration is present, you could parse the output of
nix eval --json $FLAKE#nixosConfigurations --apply builtins.attrNames
and look for$(hostname)
.Example output of above command:
To check wether a home-manager configuration is present, you could parse the output of
nix eval --json $FLAKE#homeConfigurations --apply builtins.attrNames
and look for an entry in the form of$(whoami)@$(hostname)
or just$(whoami)
.Example output of above command:
Which exact commands should Topgrade run?
nix --experimental-features "nix-command flakes" flake update --flake $FLAKE
;nh os switch
;nh home switch
.Does it have a
--dry-run
option? i.e., print what should be done and exitnix flake update
does NOT have--dry-run
, butnh
has--dry
.Does it need the user to confirm the execution? And does it provide a
--yes
option to skip this step?nix flake update
never asks for user input;nh os switch
never asks by itself unless you specify--ask
, but requires a sudo password to actually finish the update;nh home switch
never asks for confirmation unless--ask
is specified.More information
I know how to test this feature if someone were to implement it. I am willing to do it myself though.
NOTE: where I specified any nix command it is a good idea to use
nix --experimental-features "nix-command flakes"
as in some systems this isn't enabled yet and nix will refuse to do anything with flakes when it isn't set.The text was updated successfully, but these errors were encountered: