nixos-*: init as package

Move all the nixos-* scripts from the nixos distribution as real
packages in the pkgs/ package set.

This allows non-nixos users to run the script as well. For example,
deploying a remote machine with:

    nixos-rebuild --target-host root@hostname --build-host root@hostname
This commit is contained in:
zimbatm 2018-10-09 23:10:45 +02:00
parent b7a07313cc
commit 1875344542
No known key found for this signature in database
GPG Key ID: 71BAF6D40C1D63D7
17 changed files with 110 additions and 66 deletions

View File

@ -6,77 +6,35 @@
with lib;
let
makeProg = args: pkgs.substituteAll (args // {
dir = "bin";
isExecutable = true;
});
nixos-build-vms = makeProg {
name = "nixos-build-vms";
src = ./nixos-build-vms/nixos-build-vms.sh;
};
nixos-install = makeProg {
name = "nixos-install";
src = ./nixos-install.sh;
nix = config.nix.package.out;
path = makeBinPath [ nixos-enter ];
};
nixos-rebuild =
let fallback = import ./nix-fallback-paths.nix; in
makeProg {
name = "nixos-rebuild";
src = ./nixos-rebuild.sh;
nix = config.nix.package.out;
nix_x86_64_linux = fallback.x86_64-linux;
nix_i686_linux = fallback.i686-linux;
};
nixos-generate-config = makeProg {
name = "nixos-generate-config";
src = ./nixos-generate-config.pl;
path = [ pkgs.btrfs-progs ];
perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl";
inherit (config.system.nixos) release;
};
nixos-option = makeProg {
name = "nixos-option";
src = ./nixos-option.sh;
};
nixos-version = makeProg {
name = "nixos-version";
src = ./nixos-version.sh;
inherit (config.system.nixos) version codeName revision;
};
nixos-enter = makeProg {
name = "nixos-enter";
src = ./nixos-enter.sh;
};
nixos-build-vms = pkgs.nixos-build-vms;
nixos-enter = pkgs.nixos-enter;
nixos-generate-config = pkgs.nixos-generate-config.override { inherit (config.system.nixos) release; };
nixos-install = pkgs.nixos-install.override { nix = config.nix.package; };
nixos-option = pkgs.nixos-option;
nixos-rebuild = pkgs.nixos-rebuild.override { nix = config.nix.package; };
nixos-version = pkgs.nixos-version.override { inherit (config.system.nixos) version codeName revision; };
in
{
config = {
environment.systemPackages =
[ nixos-build-vms
nixos-install
nixos-rebuild
nixos-generate-config
nixos-option
nixos-version
nixos-enter
];
environment.systemPackages = [
nixos-build-vms
nixos-enter
nixos-generate-config
nixos-install
nixos-option
nixos-rebuild
nixos-version
];
system.build = {
inherit nixos-install nixos-generate-config nixos-option nixos-rebuild nixos-enter;
inherit
nixos-enter
nixos-generate-config
nixos-install
nixos-option
nixos-rebuild
;
};
};
}

View File

@ -0,0 +1,7 @@
{ substituteAll }:
substituteAll {
name = "nixos-build-vms";
dir = "bin";
isExecutable = true;
src = ./nixos-build-vms.sh;
}

View File

@ -0,0 +1,7 @@
{ substituteAll }:
substituteAll {
name = "nixos-enter";
dir = "bin";
isExecutable = true;
src = ./nixos-enter.sh;
}

View File

@ -0,0 +1,16 @@
{ substituteAll
, btrfs-progs
, perl
, perlPackages
, lib
, release ? lib.trivial.release
}:
substituteAll {
name = "nixos-generate-config";
dir = "bin";
isExecutable = true;
src = ./nixos-generate-config.pl;
path = [ btrfs-progs ];
perl = "${perl}/bin/perl -I${perlPackages.FileSlurp}/lib/perl5/site_perl";
inherit release;
}

View File

@ -0,0 +1,13 @@
{ substituteAll
, lib
, nix
, nixos-enter
}:
substituteAll {
name = "nixos-install";
dir = "bin";
isExecutable = true;
src = ./nixos-install.sh;
nix = nix.out;
path = lib.makeBinPath [ nixos-enter ];
}

View File

@ -0,0 +1,7 @@
{ substituteAll }:
substituteAll {
name = "nixos-option";
dir = "bin";
isExecutable = true;
src = ./nixos-option.sh;
}

View File

@ -0,0 +1,13 @@
{ substituteAll, nix }:
let
fallback = import ./nix-fallback-paths.nix;
in
substituteAll {
name = "nixos-rebuild";
dir = "bin";
isExecutable = true;
src = ./nixos-rebuild.sh;
nix = nix.out;
nix_x86_64_linux = fallback.x86_64-linux;
nix_i686_linux = fallback.i686-linux;
}

View File

@ -0,0 +1,13 @@
{ substituteAll
, lib
, version ? lib.trivial.version
, codeName ? "unknown"
, revision ? lib.trivial.revisionWithDefault "master"
}:
substituteAll {
name = "nixos-version";
dir = "bin";
isExecutable = true;
src = ./nixos-version.sh;
inherit version codeName revision;
}

View File

@ -21951,6 +21951,16 @@ with pkgs;
nixStable
nixUnstable;
# NixOS tools
nixos-build-vms = callPackage ../tools/nixos/nixos-build-vms { };
nixos-enter = callPackage ../tools/nixos/nixos-enter { };
nixos-generate-config = callPackage ../tools/nixos/nixos-generate-config { };
nixos-install = callPackage ../tools/nixos/nixos-install { };
nixos-option = callPackage ../tools/nixos/nixos-option { };
nixos-rebuild = callPackage ../tools/nixos/nixos-rebuild { };
nixos-version = callPackage ../tools/nixos/nixos-version { };
nixops = callPackage ../tools/package-management/nixops { };
nixopsUnstable = lowPrio (callPackage ../tools/package-management/nixops/unstable.nix { });