-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
52 lines (44 loc) · 1.33 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
{
description = "Learning x86_64 assembly using Flat Assembler";
inputs = {
flake-utils.url = github:numtide/flake-utils;
};
outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
program-name = "fasm-hello";
in
{
# nix develop, or automatically when using direnv
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
fasm
];
shellHook = ''
export PATH=$(realpath ./result/bin):$PATH
'';
};
# nix build
# creates binary in ./result/bin/fasm-hello
packages.default = pkgs.stdenvNoCC.mkDerivation {
name = "${program-name}";
version = "0.1.0";
src = ./.;
buildInputs = with pkgs; [ fasm ];
buildPhase = ''
${pkgs.fasm}/bin/fasm ${program-name}.asm ${program-name}
'';
installPhase = ''
mkdir -p $out/bin
cp ${program-name} $out/bin/
chmod +x $out/bin/${program-name}
'';
meta = {
description = "A simple Hello World program in Flat Assembler (fasm) for Linux";
license = pkgs.lib.licenses.mit;
};
};
}
);
}