Squash of #136
https://github.com/numtide/system-manager/pull/136 Contents: @r-vdp Avoid rec ac4a95a @r-vdp Avoid re-importing nixpkgs multiple times 21bd839 @r-vdp Avoid building the application twice 8706306 @r-vdp Run clippy as part of the check phase ca50566 @r-vdp flake.lock: Update 1d968fb @r-vdp Adapt systemd module after merge of NixOS/nixpkgs#311394 270e3f0 @r-vdp Add nix-vm-test flake input 58dd3f9 @r-vdp Merge remote-tracking branch 'origin/main' into reduce_flake_deps a92a05f @r-vdp flake.lock: Update 9843716 Co-authored-by: r-vdp <ramses@well-founded.dev>
This commit is contained in:
parent
37d944cc5f
commit
c099b40594
6 changed files with 188 additions and 152 deletions
8
Cargo.lock
generated
8
Cargo.lock
generated
|
|
@ -62,9 +62,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.91"
|
||||
version = "1.0.90"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8"
|
||||
checksum = "37bf3594c4c988a53154954629820791dde498571819ae4ca50ca811e060cc95"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
|
|
@ -274,9 +274,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.88"
|
||||
version = "1.0.87"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
|
||||
checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
|
|
|||
21
flake.lock
generated
21
flake.lock
generated
|
|
@ -1,5 +1,25 @@
|
|||
{
|
||||
"nodes": {
|
||||
"nix-vm-test": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1729365388,
|
||||
"narHash": "sha256-PRBcv8IWfXlw7DLuljqyPVAqtcj3/7RtmsKCou8dhAg=",
|
||||
"owner": "numtide",
|
||||
"repo": "nix-vm-test",
|
||||
"rev": "62092e89a2a69fa63fb4f560f48e2f874d3393bb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "nix-vm-test",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1729256560,
|
||||
|
|
@ -18,6 +38,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nix-vm-test": "nix-vm-test",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
39
flake.nix
39
flake.nix
|
|
@ -1,10 +1,17 @@
|
|||
{
|
||||
description = "Manage system config using nix on any distro";
|
||||
|
||||
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
|
||||
nix-vm-test = {
|
||||
url = "github:numtide/nix-vm-test";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
inputs:
|
||||
let
|
||||
systems = [
|
||||
"aarch64-linux"
|
||||
|
|
@ -12,22 +19,22 @@
|
|||
];
|
||||
eachSystem =
|
||||
f:
|
||||
nixpkgs.lib.genAttrs systems (
|
||||
inputs.nixpkgs.lib.genAttrs systems (
|
||||
system:
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
lib = import ./nix/lib.nix { inherit nixpkgs; };
|
||||
lib = import ./nix/lib.nix { inherit (inputs) nixpkgs; };
|
||||
|
||||
packages = eachSystem (
|
||||
{ pkgs, system }:
|
||||
import ./packages.nix { inherit pkgs; }
|
||||
// {
|
||||
default = self.packages.${system}.system-manager;
|
||||
default = inputs.self.packages.${system}.system-manager;
|
||||
}
|
||||
);
|
||||
|
||||
|
|
@ -37,7 +44,7 @@
|
|||
};
|
||||
|
||||
# Only useful for quick tests
|
||||
systemConfigs.default = self.lib.makeSystemConfig {
|
||||
systemConfigs.default = inputs.self.lib.makeSystemConfig {
|
||||
modules = [ ./examples/example.nix ];
|
||||
};
|
||||
|
||||
|
|
@ -51,31 +58,23 @@
|
|||
);
|
||||
|
||||
checks = (
|
||||
nixpkgs.lib.recursiveUpdate
|
||||
inputs.nixpkgs.lib.recursiveUpdate
|
||||
(eachSystem (
|
||||
{ system, ... }:
|
||||
{
|
||||
system-manager = self.packages.${system}.system-manager;
|
||||
system-manager = inputs.self.packages.${system}.system-manager;
|
||||
}
|
||||
))
|
||||
{
|
||||
x86_64-linux =
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
nix-vm-test-src = builtins.fetchTarball {
|
||||
url = "https://github.com/numtide/nix-vm-test/archive/7901cec00670681b3e405565cb7bffe6a9368240.tar.gz";
|
||||
sha256 = "0m82a40r3j7qinp3y6mh36da89dkwvpalz6a4znx9rqp6kh3885x";
|
||||
};
|
||||
nix-vm-test = import "${nix-vm-test-src}/lib.nix" {
|
||||
inherit nixpkgs;
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
(import ./test/nix/modules {
|
||||
inherit system;
|
||||
inherit (nixpkgs) lib;
|
||||
inherit nix-vm-test;
|
||||
system-manager = self;
|
||||
inherit (inputs.nixpkgs) lib;
|
||||
nix-vm-test = inputs.nix-vm-test.lib.${system};
|
||||
system-manager = inputs.self;
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
|||
22
nix/lib.nix
22
nix/lib.nix
|
|
@ -3,7 +3,8 @@
|
|||
lib ? import "${nixpkgs}/lib",
|
||||
nixos ? "${nixpkgs}/nixos",
|
||||
}:
|
||||
rec {
|
||||
let
|
||||
self = {
|
||||
# Function that can be used when defining inline modules to get better location
|
||||
# reporting in module-system errors.
|
||||
# Usage example:
|
||||
|
|
@ -31,7 +32,7 @@ rec {
|
|||
...
|
||||
}:
|
||||
{
|
||||
_file = "${printAttrPos (builtins.unsafeGetAttrPos "a" { a = null; })}: inline module";
|
||||
_file = "${self.printAttrPos (builtins.unsafeGetAttrPos "a" { a = null; })}: inline module";
|
||||
_module.args = {
|
||||
pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; };
|
||||
utils = import "${nixos}/lib/utils.nix" {
|
||||
|
|
@ -39,8 +40,7 @@ rec {
|
|||
};
|
||||
# Pass the wrapped system-manager binary down
|
||||
# TODO: Use nixpkgs version by default.
|
||||
inherit
|
||||
(import ../packages.nix { pkgs = import nixpkgs { system = config.nixpkgs.hostPlatform; }; })
|
||||
inherit (import ../packages.nix { inherit pkgs; })
|
||||
system-manager
|
||||
;
|
||||
};
|
||||
|
|
@ -57,9 +57,7 @@ rec {
|
|||
] ++ modules;
|
||||
}).config;
|
||||
|
||||
# Get the system as it was defined in the modules.
|
||||
system = config.nixpkgs.hostPlatform;
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
inherit (config.nixpkgs) pkgs;
|
||||
|
||||
returnIfNoAssertions =
|
||||
drv:
|
||||
|
|
@ -124,20 +122,22 @@ rec {
|
|||
|
||||
activateProfileSnippet =
|
||||
{ node, profile }:
|
||||
mkTestPreamble {
|
||||
self.mkTestPreamble {
|
||||
inherit node profile;
|
||||
action = "activate";
|
||||
};
|
||||
deactivateProfileSnippet =
|
||||
{ node, profile }:
|
||||
mkTestPreamble {
|
||||
self.mkTestPreamble {
|
||||
inherit node profile;
|
||||
action = "deactivate";
|
||||
};
|
||||
prepopulateProfileSnippet =
|
||||
{ node, profile }:
|
||||
mkTestPreamble {
|
||||
self.mkTestPreamble {
|
||||
inherit node profile;
|
||||
action = "prepopulate";
|
||||
};
|
||||
}
|
||||
};
|
||||
in
|
||||
self
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@
|
|||
example = "x86_64-linux";
|
||||
default = throw "the option nixpkgs.hostPlatform needs to be set.";
|
||||
};
|
||||
|
||||
pkgs = lib.mkOption {
|
||||
type = lib.types.pkgs;
|
||||
description = ''The pkgs module argument.'';
|
||||
default = pkgs;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
|
||||
assertions = lib.mkOption {
|
||||
|
|
|
|||
11
packages.nix
11
packages.nix
|
|
@ -31,6 +31,7 @@ in
|
|||
pkg-config,
|
||||
makeWrapper,
|
||||
nix,
|
||||
clippy,
|
||||
}:
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "system-manager";
|
||||
|
|
@ -42,7 +43,15 @@ in
|
|||
pkg-config
|
||||
makeWrapper
|
||||
];
|
||||
checkType = "debug"; # might not be required?
|
||||
|
||||
nativeCheckInputs = [
|
||||
clippy
|
||||
];
|
||||
|
||||
preCheck = ''
|
||||
${lib.getExe pkgs.cargo} clippy
|
||||
'';
|
||||
|
||||
# TODO: Is prefixing nix here the correct approach?
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/system-manager \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue