nix! flakes!

This commit is contained in:
august kline 2024-04-10 18:10:25 -04:00
parent 5f65c32e56
commit b1b9c64468
3 changed files with 175 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ log
george.o
.DS_Store
*.bin
/result

112
flake.lock Normal file
View File

@ -0,0 +1,112 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1698420672,
"narHash": "sha256-/TdeHMPRjjdJub7p7+w55vyABrsJlt5QkznPYy55vKA=",
"owner": "nmattia",
"repo": "naersk",
"rev": "aeb58d5e8faead8980a807c840232697982d47b9",
"type": "github"
},
"original": {
"owner": "nmattia",
"ref": "master",
"repo": "naersk",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1712696601,
"narHash": "sha256-puFPFSa/RC83JilUgB48/VL387eu2QN066Jv6X971LY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "062fc6cf99d809921ecef47317752fc92468e6ae",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1712608508,
"narHash": "sha256-vMZ5603yU0wxgyQeHJryOI+O61yrX2AHwY6LOFyV1gM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4cba8b53da471aea2ab2b0c1f30a81e7c451f4b6",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-compat": "flake-compat",
"naersk": "naersk",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

62
flake.nix Normal file
View File

@ -0,0 +1,62 @@
{
inputs = {
naersk.url = "github:nmattia/naersk/master";
# This must be the stable nixpkgs if you're running the app on a
# stable NixOS install. Mixing EGL library versions doesn't work.
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
flake-compat = {
url = github:edolstra/flake-compat;
flake = false;
};
};
outputs = { self, nixpkgs, utils, naersk, ... }:
utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
naersk-lib = pkgs.callPackage naersk { };
libPath = with pkgs; lib.makeLibraryPath [
libxkbcommon
wayland
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
];
in
{
defaultPackage = naersk-lib.buildPackage {
src = ./.;
doCheck = true;
pname = "georgeemu";
nativeBuildInputs = [ pkgs.makeWrapper ];
buildInputs = with pkgs; [
xorg.libxcb
];
postInstall = ''
wrapProgram "$out/bin/georgeemu" --prefix LD_LIBRARY_PATH : "${libPath}"
'';
};
defaultApp = utils.lib.mkApp {
drv = self.defaultPackage."${system}";
};
devShell = with pkgs; mkShell {
buildInputs = [
cargo
cargo-insta
pre-commit
rust-analyzer
rustPackages.clippy
rustc
rustfmt
xorg.libxcb
];
RUST_SRC_PATH = rustPlatform.rustLibSrc;
LD_LIBRARY_PATH = libPath;
};
});
}