diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index c202f83f..1c19e543 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,5 @@ c-plus-plus.conf.sh /make-setup/_tmp CMakeLists.txt - -.idea/ \ No newline at end of file +.direnv +.idea/ diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..13f9c124 --- /dev/null +++ b/flake.lock @@ -0,0 +1,41 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1634319982, + "narHash": "sha256-jJ83sVEX20uT0AulXm351TdlBX3ApFmCwF+U/FGdw6Q=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bcd05cd2ab0a3f87718ddd1dfc61e6ba6f9f7087", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "utils": "utils" + } + }, + "utils": { + "locked": { + "lastModified": 1631561581, + "narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..8d1eb1e1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + inputs = { + utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, utils, nixpkgs, ... }: utils.lib.eachDefaultSystem + (system: + let + pkgs = import nixpkgs { inherit system; }; + version = with builtins; head (match ".*VERSION=([[:digit:].]+).*" (readFile ./docs/setup.bash)); + in { + defaultPackage = with pkgs; stdenv.mkDerivation { + name = "refal-5-lambda"; + inherit version; + + src = ./.; + + dontStrip = true; + + patchPhase = '' + runHook prePatchPhase + find -type f -exec sed -i '1,1s\#!/bin/bash\#!${pkgs.bash}/bin/bash\' '{}' ';' + runHook postPatchPhase + ''; + buildPhase = '' + runHook preBuildPhase + ./bootstrap.sh + runHook postBuildPhase + ''; + installPhase = '' + runHook preInstallPhase + mkdir -p $out + mv bin lib c-plus-plus.conf.sh $out + runHook postInstallPhase + ''; + + }; + }); +}