Skip to content
Snippets Groups Projects
Commit c6b0fdd0 authored by Eduardo Trujillo's avatar Eduardo Trujillo
Browse files

feat: Add Nix Flake

parent 61a1780c
No related branches found
No related tags found
No related merge requests found
......@@ -8,6 +8,9 @@ description = "A NetworkManager reactor. If-this-then-that for NetworkManager."
repository = "https://gitlab.chromabits.com/etcinit/nm-reactor"
exclude = ["third_party"]
[workspace]
members = ["dbus_codegen"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
......
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1671096816,
"narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=",
"owner": "nix-community",
"repo": "naersk",
"rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1673180965,
"narHash": "sha256-gMhL6w9RVluvPs+irJ9n0Q1BphZm+Ek4XGn5Ow7YQ3k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0c9aadc8eff6daaa5149d2df9e6c49baaf44161c",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1673180965,
"narHash": "sha256-gMhL6w9RVluvPs+irJ9n0Q1BphZm+Ek4XGn5Ow7YQ3k=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "0c9aadc8eff6daaa5149d2df9e6c49baaf44161c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = {
self,
flake-utils,
naersk,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = (import nixpkgs) {
inherit system;
};
naersk' = pkgs.callPackage naersk {};
in rec {
defaultPackage = naersk'.buildPackage {
src = ./.;
buildInputs = with pkgs; [dbus];
nativeBuildInputs = with pkgs; [pkg-config];
};
devShell = pkgs.mkShell {
buildInputs = with pkgs; [dbus];
nativeBuildInputs = with pkgs; [rustc cargo pkg-config];
};
formatter = nixpkgs.legacyPackages.${system}.alejandra;
}
)
// {
nixosModules.home-manager.nm-reactor = import ./home-manager.nix self;
};
}
outputs: {
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.nm-reactor;
in {
options.services.nm-reactor = {
enable = mkEnableOption "Enables the nm-reactor daemon";
package = mkOption {
type = types.package;
default = outputs.defaultPackage.${pkgs.system};
description = mdDoc "The `nm-reactor` package to use.";
};
configLines = mkOption {
type = types.lines;
description = mdDoc "The contents of the configuration file";
};
};
config = mkIf cfg.enable {
xdg.configFile."nm-reactor/config.yaml" = {
text = cfg.configLines;
};
home.packages = [cfg.package];
systemd.user.services.nm-reactor = {
Unit = {
Description = ''
A NetworkManager reactor. If-this-then-that for NetworkManager.
'';
Requires = ["NetworkManager.service"];
};
Service = {
ExecStart = "${cfg.package}/bin/nm-reactor";
Environment = "RUST_LOG=info";
};
Install.WantedBy = ["default.target"];
};
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment