nix: init rewrite
first pass of my nix rewrite nix: rename module nix: update module nix: update module nix: update module nix: refactor nix: remove package option nix: fix serviceConfig nix: add package back to module nix: update module nix: update module nix: update module nix: update module remove default.nix
This commit is contained in:
parent
91d62bf0ff
commit
087e76388d
4 changed files with 107 additions and 35 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -23,3 +23,6 @@ target/
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
|
# nix
|
||||||
|
result/
|
30
flake.lock
30
flake.lock
|
@ -38,16 +38,16 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712439257,
|
"lastModified": 1712543224,
|
||||||
"narHash": "sha256-aSpiNepFOMk9932HOax0XwNxbA38GOUVOiXfUVPOrck=",
|
"narHash": "sha256-9RSfZL1TKYdGxZwgDxwtBtsKMGR4Zgn+DAnF9s71/lU=",
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "ff0dbd94265ac470dda06a657d5fe49de93b4599",
|
"rev": "b0dab7cc34ef4d8a1b2de36178da801090bcb271",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "NixOS",
|
||||||
"ref": "nixos-unstable",
|
"ref": "nixpkgs-unstable",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,8 @@
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2",
|
||||||
|
"systems": "systems"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
|
@ -74,6 +75,21 @@
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1689347949,
|
||||||
|
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default-linux",
|
||||||
|
"rev": "31732fcf5e8fea42e59c2488ad31a0e651500f68",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default-linux",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
77
flake.nix
77
flake.nix
|
@ -1,39 +1,62 @@
|
||||||
{
|
{
|
||||||
description = "forcebot_rs flake";
|
description = "A basic flake";
|
||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
systems.url = "github:nix-systems/default-linux";
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||||
fenix.url = "github:nix-community/fenix/monthly";
|
fenix.url = "github:nix-community/fenix/monthly";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = {
|
outputs = {
|
||||||
|
self,
|
||||||
|
systems,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
fenix,
|
fenix,
|
||||||
...
|
|
||||||
} @ inputs: let
|
} @ inputs: let
|
||||||
system = "x86_64-linux";
|
eachSystem = nixpkgs.lib.genAttrs (import systems);
|
||||||
overlays = [fenix.overlays.default];
|
pkgsFor = eachSystem (system:
|
||||||
pkgs = import nixpkgs {
|
import nixpkgs {
|
||||||
inherit system overlays;
|
localSystem.system = system;
|
||||||
};
|
overlays = [fenix.overlays.default];
|
||||||
|
});
|
||||||
in {
|
in {
|
||||||
devShells.${system}.default = pkgs.mkShell {
|
packages = eachSystem (system: let
|
||||||
name = "forcebot_rs-devenv";
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
nativeBuildInputs = [pkgs.pkg-config];
|
in {
|
||||||
buildInputs = with pkgs; [openssl libiconv];
|
default = pkgsFor.${system}.rustPlatform.buildRustPackage {
|
||||||
packages = with pkgs; [
|
pname = "forcebot_rs";
|
||||||
nil
|
version = "v0.1";
|
||||||
alejandra
|
|
||||||
rust-analyzer-nightly
|
src = self;
|
||||||
(fenix.packages.${system}.complete.withComponents [
|
|
||||||
"cargo"
|
cargoLock = {
|
||||||
"clippy"
|
lockFile = ./Cargo.lock;
|
||||||
"rust-src"
|
};
|
||||||
"rustc"
|
|
||||||
"rustfmt"
|
nativeBuildInputs = with pkgs; [pkg-config];
|
||||||
])
|
buildInputs = with pkgs; [openssl];
|
||||||
];
|
|
||||||
RUST_BACKTRACE = 1;
|
doCheck = false;
|
||||||
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
|
};
|
||||||
};
|
});
|
||||||
|
devShells = eachSystem (system: {
|
||||||
|
default = pkgsFor.${system}.mkShell {
|
||||||
|
packages = with pkgsFor.${system}; [
|
||||||
|
nil
|
||||||
|
alejandra
|
||||||
|
rust-analyzer-nightly
|
||||||
|
(fenix.packages.${system}.complete.withComponents [
|
||||||
|
"cargo"
|
||||||
|
"clippy"
|
||||||
|
"rust-src"
|
||||||
|
"rustc"
|
||||||
|
"rustfmt"
|
||||||
|
])
|
||||||
|
];
|
||||||
|
RUST_BACKTRACE = 1;
|
||||||
|
RUST_SRC_PATH = "${fenix.packages.${system}.complete.rust-src}/lib/rustlib/src/rust/library";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
nixosModules.default = import ./nix/module.nix {inherit self;};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
30
nix/module.nix
Normal file
30
nix/module.nix
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{self}: {
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) types;
|
||||||
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (pkgs.stdenv.hostPlatform) system;
|
||||||
|
cfg = config.services.forcebot_rs;
|
||||||
|
in {
|
||||||
|
options.services.forcebot_rs = {
|
||||||
|
enable = mkEnableOption ''
|
||||||
|
Enable forcebot
|
||||||
|
'';
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
type = types.package;
|
||||||
|
default = self.packages.${system}.default;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
systemd.services.forcebot_rs = {
|
||||||
|
wantedBy = ["multi-user.target"];
|
||||||
|
serviceConfig.ExecStart = "${cfg.package}/bin/forcebot_rs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue