-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
64 lines (57 loc) · 1.77 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
description = "Hello world Rust program statically linked against musl";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, }:
let
# Should work with other targets, but not tested.
supportedSystems = [ "x86_64-linux" ];
# Helper function to generate an attrset '{ x86_64-linux = f "x86_64-linux"; ... }'.
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
# Nixpkgs instantiated for supported system types.
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
in
{
packages = forAllSystems (system:
let
pkgs = nixpkgsFor.${system}.pkgsStatic;
pkgs-full = nixpkgsFor.${system};
in rec {
default = pkgs.rustPlatform.buildRustPackage {
pname = "h8r";
version = "2.0.1";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
};
deb = pkgs.stdenv.mkDerivation {
name = "h8r";
phases = [ "installPhase" ];
installPhase = ''
mkdir -p ./dpkg/usr/bin
mkdir -p $out
cp ${default}/bin/h8r ./dpkg/usr/bin
mkdir -p ./dpkg/DEBIAN
cat > ./dpkg/DEBIAN/control <<EOF
Package: h8r
Version: ${default.version}
Architecture: amd64
Maintainer: shebpamm
Description: h8r
EOF
${pkgs-full.dpkg}/bin/dpkg-deb --build ./dpkg
mv ./dpkg.deb $out/h8r.deb
'';
};
});
devShells = forAllSystems (system:
let pkgs = nixpkgsFor.${system};
in {
default = pkgs.mkShell {
buildInputs = with pkgs; [
cargo
];
};
});
};
}