Use crane to build faster.
This commit is contained in:
parent
7a8fe92371
commit
49f92dd6b8
3 changed files with 123 additions and 56 deletions
72
flake.lock
generated
72
flake.lock
generated
|
|
@ -1,5 +1,35 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
|
"crane": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-compat": [
|
||||||
|
"pre-commit-hooks",
|
||||||
|
"flake-compat"
|
||||||
|
],
|
||||||
|
"flake-utils": [
|
||||||
|
"flake-utils"
|
||||||
|
],
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"rust-overlay": [
|
||||||
|
"rust-overlay"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1675902425,
|
||||||
|
"narHash": "sha256-ASv/7bZIoP/2FON+RNFYYUlmpleZAjKKb4XF1Pmhu4g=",
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"rev": "8c34e5ecadc691dd64b31b9317eb35d7cdaa636b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "ipetkov",
|
||||||
|
"repo": "crane",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"devshell": {
|
"devshell": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": [
|
"flake-utils": [
|
||||||
|
|
@ -10,11 +40,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1671489820,
|
"lastModified": 1675790942,
|
||||||
"narHash": "sha256-qoei5HDJ8psd1YUPD7DhbHdhLIT9L2nadscp4Qk37uk=",
|
"narHash": "sha256-UfXATFXxACtdMQmwRZIdOc6CT4mwgbZBAnGxiUkgUM4=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "devshell",
|
"repo": "devshell",
|
||||||
"rev": "5aa3a8039c68b4bf869327446590f4cdf90bb634",
|
"rev": "6fe837bb4f540a1832522ec54604c453757836b2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -77,11 +107,11 @@
|
||||||
},
|
},
|
||||||
"nix-filter": {
|
"nix-filter": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1666547822,
|
"lastModified": 1675361037,
|
||||||
"narHash": "sha256-razwnAybPHyoAyhkKCwXdxihIqJi1G6e1XP4FQOJTEs=",
|
"narHash": "sha256-CTbDuDxFD3U3g/dWUB+r+B/snIe+qqP1R+1myuFGe2I=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "nix-filter",
|
"repo": "nix-filter",
|
||||||
"rev": "1a3b735e13e90a8d2fd5629f2f8363bd7ffbbec7",
|
"rev": "e1b2f96c2a31415f362268bc48c3fccf47dff6eb",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -92,11 +122,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675115703,
|
"lastModified": 1675763311,
|
||||||
"narHash": "sha256-4zetAPSyY0D77x+Ww9QBe8RHn1akvIvHJ/kgg8kGDbk=",
|
"narHash": "sha256-bz0Q2H3mxsF1CUfk26Sl9Uzi8/HFjGFD/moZHz1HebU=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "2caf4ef5005ecc68141ecb4aac271079f7371c44",
|
"rev": "fab09085df1b60d6a0870c8a89ce26d5a4a708c2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -135,11 +165,11 @@
|
||||||
"nixpkgs-stable": "nixpkgs-stable"
|
"nixpkgs-stable": "nixpkgs-stable"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675169698,
|
"lastModified": 1675688762,
|
||||||
"narHash": "sha256-C1wFiyJ+4SRvIsFkdMIN1Fa+58APmyTGKWpX9EKOehM=",
|
"narHash": "sha256-oit/SxMk0B380ASuztBGQLe8TttO1GJiXF8aZY9AYEc=",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "ce4efeec34c6eb35ba07b8fceaae87d6b46c1c5f",
|
"rev": "ab608394886fb04b8a5df3cb0bab2598400e3634",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -150,6 +180,7 @@
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
|
"crane": "crane",
|
||||||
"devshell": "devshell",
|
"devshell": "devshell",
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"nix-filter": "nix-filter",
|
"nix-filter": "nix-filter",
|
||||||
|
|
@ -169,11 +200,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1675218841,
|
"lastModified": 1675909822,
|
||||||
"narHash": "sha256-/aARbO0v7XlyFaG6vzYKp9ImG6pX5a8Ss4McQ4u9BJs=",
|
"narHash": "sha256-DnyjGN0R7Vx/1a9Th9yBp+9tG2QGrh+cZ9j4e3cg3PI=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "b86e094432c5576867b75a2834babf06aafd6c49",
|
"rev": "50ee0fa4d0eeadd97c63be57e14b01d531e79ed7",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -183,12 +214,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"treefmt-nix": {
|
"treefmt-nix": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1674470002,
|
"lastModified": 1675939481,
|
||||||
"narHash": "sha256-Tk1VaMeBTMMGEZeqv3TEwrTAdR9fYb3EH/TPI27AdKk=",
|
"narHash": "sha256-LwwcWeyExA02GGn8QCQfZjft+blg101OXBQWglCqPVA=",
|
||||||
"owner": "numtide",
|
"owner": "numtide",
|
||||||
"repo": "treefmt-nix",
|
"repo": "treefmt-nix",
|
||||||
"rev": "d5ed9a1e6793f99b2e179d5dec9639e48ef22db7",
|
"rev": "e9033eca3d7139fd499f310023ddc3bb5abff515",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
100
flake.nix
100
flake.nix
|
|
@ -4,21 +4,39 @@
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
devshell = {
|
devshell = {
|
||||||
url = "github:numtide/devshell";
|
url = "github:numtide/devshell";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs = {
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
nix-filter.url = "github:numtide/nix-filter";
|
nix-filter.url = "github:numtide/nix-filter";
|
||||||
pre-commit-hooks = {
|
pre-commit-hooks = {
|
||||||
url = "github:cachix/pre-commit-hooks.nix";
|
url = "github:cachix/pre-commit-hooks.nix";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs = {
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
rust-overlay = {
|
rust-overlay = {
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs = {
|
||||||
inputs.flake-utils.follows = "flake-utils";
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
crane = {
|
||||||
|
url = "github:ipetkov/crane";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.follows = "flake-utils";
|
||||||
|
rust-overlay.follows = "rust-overlay";
|
||||||
|
flake-compat.follows = "pre-commit-hooks/flake-compat";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
treefmt-nix = {
|
||||||
|
url = "github:numtide/treefmt-nix";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
|
|
@ -27,6 +45,7 @@
|
||||||
, flake-utils
|
, flake-utils
|
||||||
, nix-filter
|
, nix-filter
|
||||||
, rust-overlay
|
, rust-overlay
|
||||||
|
, crane
|
||||||
, devshell
|
, devshell
|
||||||
, treefmt-nix
|
, treefmt-nix
|
||||||
, pre-commit-hooks
|
, pre-commit-hooks
|
||||||
|
|
@ -40,6 +59,34 @@
|
||||||
};
|
};
|
||||||
rust = pkgs.rust-bin.stable."1.66.0";
|
rust = pkgs.rust-bin.stable."1.66.0";
|
||||||
llvm = pkgs.llvmPackages_latest;
|
llvm = pkgs.llvmPackages_latest;
|
||||||
|
|
||||||
|
craneLib = (crane.mkLib pkgs).overrideToolchain rust.default;
|
||||||
|
|
||||||
|
# Common derivation arguments used for all builds
|
||||||
|
commonArgs = {
|
||||||
|
src = craneLib.cleanCargoSource ./.;
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
dbus
|
||||||
|
];
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
pkg-config
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Build only the cargo dependencies
|
||||||
|
cargoArtifacts = craneLib.buildDepsOnly (commonArgs // {
|
||||||
|
pname = "system-manager";
|
||||||
|
});
|
||||||
|
|
||||||
|
system-manager = craneLib.buildPackage (commonArgs // {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
});
|
||||||
|
|
||||||
|
system-manager-clippy = craneLib.cargoClippy (commonArgs // {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||||
|
});
|
||||||
|
|
||||||
# treefmt-nix configuration
|
# treefmt-nix configuration
|
||||||
treefmt.config = {
|
treefmt.config = {
|
||||||
projectRootFile = "flake.nix";
|
projectRootFile = "flake.nix";
|
||||||
|
|
@ -58,31 +105,12 @@
|
||||||
modules = [
|
modules = [
|
||||||
./nix/modules
|
./nix/modules
|
||||||
];
|
];
|
||||||
inherit (self.packages.${system}) service-manager;
|
inherit (self.packages.${system}) system-manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = {
|
packages = {
|
||||||
service-manager =
|
inherit system-manager;
|
||||||
pkgs.rustPlatform.buildRustPackage
|
default = self.packages.${system}.system-manager;
|
||||||
{
|
|
||||||
pname = "service-manager";
|
|
||||||
version = (pkgs.lib.importTOML ./Cargo.toml).package.version;
|
|
||||||
|
|
||||||
src = nix-filter.lib {
|
|
||||||
root = ./.;
|
|
||||||
include = [ "Cargo.toml" "Cargo.lock" (nix-filter.lib.inDirectory "src") ];
|
|
||||||
};
|
|
||||||
|
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
pkg-config
|
|
||||||
];
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
dbus
|
|
||||||
];
|
|
||||||
};
|
|
||||||
default = self.packages.${system}.service-manager;
|
|
||||||
};
|
};
|
||||||
devShells.default = pkgs.devshell.mkShell {
|
devShells.default = pkgs.devshell.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
|
|
@ -93,6 +121,7 @@
|
||||||
extensions = [ "rust-src" ];
|
extensions = [ "rust-src" ];
|
||||||
})
|
})
|
||||||
(treefmt-nix.lib.mkWrapper pkgs treefmt.config)
|
(treefmt-nix.lib.mkWrapper pkgs treefmt.config)
|
||||||
|
self.packages.${system}.system-manager
|
||||||
];
|
];
|
||||||
env = [
|
env = [
|
||||||
{
|
{
|
||||||
|
|
@ -117,10 +146,7 @@
|
||||||
value = "1";
|
value = "1";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
devshell.startup.pre-commit.text = self.checks.${system}.pre-commit-check.shellHook;
|
devshell.startup.pre-commit.text = (pre-commit-hooks.lib.${system}.run {
|
||||||
};
|
|
||||||
checks = {
|
|
||||||
pre-commit-check = pre-commit-hooks.lib.${system}.run {
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
hooks = {
|
hooks = {
|
||||||
check-format = {
|
check-format = {
|
||||||
|
|
@ -135,7 +161,13 @@
|
||||||
pass_filenames = false;
|
pass_filenames = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
}).shellHook;
|
||||||
|
};
|
||||||
|
checks = {
|
||||||
|
inherit
|
||||||
|
# Build the crate as part of `nix flake check` for convenience
|
||||||
|
system-manager
|
||||||
|
system-manager-clippy;
|
||||||
};
|
};
|
||||||
}))
|
}))
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -95,14 +95,13 @@ fn link_services(services: Services) -> Result<LinkedServices> {
|
||||||
name.to_owned(),
|
name.to_owned(),
|
||||||
LinkedServiceConfig::new(service_config.to_owned(), linked_path)?,
|
LinkedServiceConfig::new(service_config.to_owned(), linked_path)?,
|
||||||
);
|
);
|
||||||
Ok(linked_services)
|
|
||||||
}
|
}
|
||||||
e @ Err(_) => {
|
e @ Err(_) => {
|
||||||
log::error!("Error linking service {}, skipping.", name);
|
log::error!("Error linking service {}, skipping.", name);
|
||||||
log::error!("{:?}", e);
|
log::error!("{:?}", e);
|
||||||
Ok(linked_services)
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
Ok(linked_services)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +189,7 @@ where
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Service {}: Error {}, please consult the logs",
|
"Service {}: error {}, please consult the logs",
|
||||||
service,
|
service,
|
||||||
log_action
|
log_action
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue