nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 callPackage,
3 substitute,
4 runtimeShell,
5 coreutils,
6 gnused,
7 gnugrep,
8 jq,
9 util-linux,
10 nix,
11 lib,
12 nixosTests,
13 installShellFiles,
14 binlore,
15 nixos-rebuild,
16}:
17let
18 fallback = import ./../../../../nixos/modules/installer/tools/nix-fallback-paths.nix;
19in
20substitute {
21 name = "nixos-rebuild";
22 src = ./nixos-rebuild.sh;
23 dir = "bin";
24 isExecutable = true;
25
26 substitutions = [
27 "--subst-var-by"
28 "runtimeShell"
29 runtimeShell
30 "--subst-var-by"
31 "nix"
32 nix
33 "--subst-var-by"
34 "nix_x86_64_linux"
35 fallback.x86_64-linux
36 "--subst-var-by"
37 "nix_i686_linux"
38 fallback.i686-linux
39 "--subst-var-by"
40 "nix_aarch64_linux"
41 fallback.aarch64-linux
42 "--subst-var-by"
43 "path"
44 (lib.makeBinPath [
45 coreutils
46 gnused
47 gnugrep
48 jq
49 util-linux
50 ])
51 ];
52
53 nativeBuildInputs = [
54 installShellFiles
55 ];
56
57 postInstall = ''
58 installManPage ${./nixos-rebuild.8}
59
60 installShellCompletion \
61 --bash ${./_nixos-rebuild}
62 '';
63
64 # run some a simple installer tests to make sure nixos-rebuild still works for them
65 passthru.tests = {
66 install-bootloader = nixosTests.nixos-rebuild-install-bootloader;
67 repl = callPackage ./test/repl.nix { };
68 simple-installer = nixosTests.installer.simple;
69 specialisations = nixosTests.nixos-rebuild-specialisations;
70 target-host = nixosTests.nixos-rebuild-target-host;
71 };
72
73 # nixos-rebuild can’t execute its arguments
74 # (but it can run ssh with the with the options stored in $NIX_SSHOPTS,
75 # and ssh can execute its arguments...)
76 passthru.binlore.out = binlore.synthesize nixos-rebuild ''
77 execer cannot bin/nixos-rebuild
78 '';
79
80 meta = {
81 description = "Rebuild your NixOS configuration and switch to it, on local hosts and remote";
82 homepage = "https://github.com/NixOS/nixpkgs/tree/master/pkgs/os-specific/linux/nixos-rebuild";
83 license = lib.licenses.mit;
84 maintainers = [ lib.maintainers.Profpatsch ];
85 teams = [ lib.teams.nixos-rebuild ];
86 mainProgram = "nixos-rebuild";
87 };
88}