feat: Nix packaging

This commit is contained in:
Jan-Bulthuis 2025-08-09 22:20:51 +02:00
parent 87e9eed8ab
commit 4a7331e3e4
6 changed files with 154 additions and 2 deletions

2
Cargo.lock generated
View File

@ -1133,7 +1133,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154"
[[package]] [[package]]
name = "madd" name = "madd-server"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",

View File

@ -1,5 +1,5 @@
[package] [package]
name = "madd" name = "madd-server"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"

61
flake.lock generated Normal file
View File

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1754498491,
"narHash": "sha256-erbiH2agUTD0Z30xcVSFcDHzkRvkRXOQ3lb887bcVrs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c2ae88e026f9525daf89587f3cbee584b92b6134",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
flake-utils,
...
}:
let
mkPackages = pkgs: {
madd-client = pkgs.callPackage ./madd-client.nix { };
madd-server = pkgs.callPackage ./madd-server.nix { };
};
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
clippy
rustfmt
rustc
];
};
packages = mkPackages pkgs;
}
)
// rec {
overlays.madd = final: prev: mkPackages final;
overlays.default = overlays.madd;
nixosModules.madd = {
};
nixosModules.default = nixosModules.madd;
};
}

31
madd-client.nix Normal file
View File

@ -0,0 +1,31 @@
{
lib,
stdenv,
makeWrapper,
curl,
coreutils,
openssh,
gnused,
}:
stdenv.mkDerivation {
pname = "madd-client";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
install -TDm777 $src/client.sh $out/bin/madd-client
wrapProgram $out/bin/madd-client \
--prefix PATH : ${
lib.makeBinPath [
curl
coreutils
openssh
gnused
]
}
'';
}

12
madd-server.nix Normal file
View File

@ -0,0 +1,12 @@
{
rustPlatform,
}:
rustPlatform.buildRustPackage {
pname = "madd-server";
version = "0.1.0";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
}