diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..b829245b --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake path:./nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1d309cd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/obj +/files/cfg +/.direnv diff --git a/nix.sh b/nix.sh new file mode 100755 index 00000000..a3712c8c --- /dev/null +++ b/nix.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env sh + +# Run a shell inside of the nix-based development environment. + +set -eu + +cd "$(dirname "$0")" + +exec nix --experimental-features 'nix-command flakes' develop path:./nix --command "${SHELL:-sh}" diff --git a/nix/flake.lock b/nix/flake.lock new file mode 100644 index 00000000..48ec786d --- /dev/null +++ b/nix/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1747467164, + "narHash": "sha256-JBXbjJ0t6T6BbVc9iPVquQI9XSXCGQJD8c8SgnUquus=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3fcbdcfc707e0aa42c541b7743e05820472bdaec", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/nix/flake.nix b/nix/flake.nix new file mode 100644 index 00000000..7f56a36a --- /dev/null +++ b/nix/flake.nix @@ -0,0 +1,35 @@ +{ + outputs = + { self, nixpkgs }: + let + shell = + { pkgs }: + pkgs.mkShell { + packages = with pkgs; [ + ncurses + dialog + perl + bashInteractive + flex + bison + buildPackages.qemu + ]; + shellHook = '' + # Do not attempt cross compilation. + export CROSS_COMPILE= + # These are set by the compiler’s shellHook but mk refuses to work when these are set. + unset CC CPP CXX AR AS LD + ''; + }; + + lib = import "${nixpkgs}/lib"; + forAll = list: f: lib.genAttrs list f; + in + { + devShells = forAll [ "x86_64-linux" ] (system: { + default = shell { + pkgs = nixpkgs.legacyPackages.${system}; + }; + }); + }; +}