1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-21 13:10:33 +00:00

Merge pull request #48122 from zimbatm/pkg-nixos-rebuild

nixos-rebuild: init as package
This commit is contained in:
zimbatm 2018-10-16 19:39:22 +02:00 committed by GitHub
commit 10addad603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 115 additions and 69 deletions

1
.codeName Normal file
View file

@ -0,0 +1 @@
Koi

View file

@ -98,6 +98,9 @@ rec {
# The current nixpkgs version number as string.
release = lib.strings.fileContents ../.version;
# Note: the first letter is bumped on every release. It's an animal.
codeName = lib.strings.fileContents ../.codeName;
# The current nixpkgs version suffix as string.
versionSuffix =
let suffixFile = ../.version-suffix;

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

@ -43,6 +43,7 @@ in
nixos.codeName = mkOption {
readOnly = true;
type = types.str;
default = lib.trivial.codeName;
description = "The NixOS release code name (e.g. <literal>Emu</literal>).";
};
@ -79,9 +80,6 @@ in
version = mkDefault (cfg.release + cfg.versionSuffix);
revision = mkIf (pathIsDirectory gitRepo) (mkDefault gitCommitId);
versionSuffix = mkIf (pathIsDirectory gitRepo) (mkDefault (".git." + gitCommitId));
# Note: the first letter is bumped on every release. It's an animal.
codeName = "Koi";
};
# Generate /etc/os-release. See

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

@ -21955,6 +21955,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 { });