aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2024-08-12 14:59:47 +0200
committerMax Audron <audron@cocaine.farm>2024-08-12 16:52:25 +0200
commitd212b916c3953d52e47b0a89890b6bf52dec7591 (patch)
tree669208bb0ec4bb1ca0e94faea3866120fdc16688 /flake.nix
parentremove jsonnet lock file (diff)
add nix build and module
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix75
1 files changed, 75 insertions, 0 deletions
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..1d0b640
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,75 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
+ nci.url = "github:yusdacra/nix-cargo-integration";
+ nci.inputs.nixpkgs.follows = "nixpkgs";
+ parts.url = "github:hercules-ci/flake-parts";
+ parts.inputs.nixpkgs-lib.follows = "nixpkgs";
+ };
+
+ outputs =
+ inputs@{ self, parts, nci, ... }:
+ parts.lib.mkFlake { inherit inputs; } ({moduleWithSystem, withSystem, ...}: {
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ ];
+ imports = [ nci.flakeModule ];
+
+ flake = {
+ # nixosModules.default = flake-parts-lib.importApply ./nix/nixos-module.nix { localFlake = self; inherit withSystem; };
+ nixosModules.default = moduleWithSystem (
+ perSystem@{ config }: # NOTE: only explicit params will be in perSystem
+ nixos@{ ... }:
+ {
+ services.catinator.package = perSystem.config.packages.default;
+ imports = [ ./nix/nixos-module.nix ];
+ }
+ );
+ };
+
+ perSystem =
+ {
+ pkgs,
+ config,
+ lib,
+ ...
+ }:
+ let
+ # shorthand for accessing this crate's outputs
+ # you can access crate outputs under `config.nci.outputs.<crate name>` (see documentation)
+ crateOutputs = config.nci.outputs."catinator";
+ in
+ {
+ nci = {
+ projects."catinator".path = ./.;
+ crates."catinator" =
+ let
+ mkDerivation = {
+ nativeBuildInputs = [ pkgs.file.dev ];
+ };
+ in
+ {
+ drvConfig = {
+ inherit mkDerivation;
+ };
+ depsDrvConfig = {
+ inherit mkDerivation;
+ };
+ };
+
+ toolchainConfig = {
+ channel = "stable";
+ targets = [ "x86_64-unknown-linux-musl" ];
+ components = [
+ "rustfmt"
+ "rust-src"
+ ];
+ };
+ };
+
+ devShells.default = crateOutputs.devShell;
+ packages.default = crateOutputs.packages.release;
+ };
+ });
+}