From eaf20e90f0f3a6e516ecab5184c96c5a897ddef3 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Thu, 31 Dec 2020 14:34:10 +0100 Subject: [PATCH 1/2] chore(.github): install-nix-action v9 -> v12 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5487648..110d55f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,5 +8,5 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v9 + - uses: cachix/install-nix-action@v12 - run: ./test/tests.bash From 4b9fd982e963ab4479fd3ce04b751a9005fcd859 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Thu, 31 Dec 2020 14:47:45 +0100 Subject: [PATCH 2/2] chore(nix): fix dependencies And a bit of shuffling to import the sources in the right way. default.nix should have the same interface than before, I make sure the existing args are still there. Originally created with niv, but removed all the bs. --- build-project.nix | 2 +- ci.nix | 16 ++--------- default.nix | 73 ++++++++++++++++------------------------------- deps.nix | 13 +++++++++ mkbin.nix | 2 +- nix/sources.json | 26 +++++++++++++++++ nix/sources.nix | 8 ++++++ test/tests.bash | 22 +++++++++----- 8 files changed, 91 insertions(+), 71 deletions(-) create mode 100644 deps.nix create mode 100644 nix/sources.json create mode 100644 nix/sources.nix diff --git a/build-project.nix b/build-project.nix index b4afb22..7ac85b7 100644 --- a/build-project.nix +++ b/build-project.nix @@ -1,4 +1,4 @@ -{ pkgs ? import {} }: +{ pkgs ? (import ./deps.nix {}).pkgs }: let easy-ps = import ( diff --git a/ci.nix b/ci.nix index 510668c..0be29c3 100644 --- a/ci.nix +++ b/ci.nix @@ -1,22 +1,12 @@ -{ pkgs ? import {} }: +{ deps ? import ./deps.nix {} +, pkgs ? deps.pkgs }: let - easy-ps = import ( - pkgs.fetchFromGitHub { - owner = "justinwoo"; - repo = "easy-purescript-nix"; - rev = "cc7196bff3fdb5957aabfe22c3fa88267047fe88"; - sha256 = "1xfl7rnmmcm8qdlsfn3xjv91my6lirs5ysy01bmyblsl10y2z9iw"; - } - ) { - inherit pkgs; - }; - spago2nix = import ./default.nix { inherit pkgs; }; in pkgs.mkShell { - buildInputs = [ easy-ps.purs spago2nix ]; + buildInputs = [ deps.purescript spago2nix ]; } diff --git a/default.nix b/default.nix index d3f281a..c78423d 100644 --- a/default.nix +++ b/default.nix @@ -1,56 +1,31 @@ -let - easy-dhall-nix = pkgs: import ( - pkgs.fetchFromGitHub { - owner = "justinwoo"; - repo = "easy-dhall-nix"; - rev = "9c4397c3af63c834929b1e6ac25eed8ce4fca5d4"; - sha256 = "1cbrqfbx29rymf4sia1ix4qssdybjdvw0is9gv7l0wsysidrcwhf"; - } - ) { - inherit pkgs; - }; - -in -{ pkgs ? import {} -, dhall-json ? (easy-dhall-nix pkgs).dhall-json-simple -, nodejs ? pkgs.nodejs-10_x +{ sources ? import ./nix/sources.nix +, deps ? import ./deps.nix { inherit sources; } +, pkgs ? deps.pkgs +, dhall-json ? deps.dhall-json +, nodejs ? deps.pkgs.nodejs-10_x }: +pkgs.stdenv.mkDerivation { + name = "spago2nix"; - let - easy-purescript-nix = import ( - pkgs.fetchFromGitHub { - owner = "justinwoo"; - repo = "easy-purescript-nix"; - rev = "1ec689df0adf8e8ada7fcfcb513876307ea34226"; - sha256 = "12hk2zbjkrq2i5fs6xb3x254lnhm9fzkcxph0a7ngxyzfykvf4hi"; - } - ) { - inherit pkgs; - }; - - in - pkgs.stdenv.mkDerivation { - name = "spago2nix"; - - src = pkgs.nix-gitignore.gitignoreSource [ ".git" ] ./.; + src = pkgs.nix-gitignore.gitignoreSource [ ".git" ] ./.; - buildInputs = [ pkgs.makeWrapper ]; + buildInputs = [ pkgs.makeWrapper ]; - installPhase = '' - mkdir -p $out/bin - target=$out/bin/spago2nix + installPhase = '' + mkdir -p $out/bin + target=$out/bin/spago2nix - >>$target echo '#!${nodejs}/bin/node' - >>$target echo "require('$src/bin/output.js')"; + >>$target echo '#!${nodejs}/bin/node' + >>$target echo "require('$src/bin/output.js')"; - chmod +x $target + chmod +x $target - wrapProgram $target \ - --prefix PATH : ${pkgs.lib.makeBinPath [ - pkgs.coreutils - pkgs.nix-prefetch-git - easy-purescript-nix.spago - dhall-json - ]} - ''; - } + wrapProgram $target \ + --prefix PATH : ${pkgs.lib.makeBinPath [ + pkgs.coreutils + pkgs.nix-prefetch-git + deps.spago + dhall-json + ]} + ''; +} diff --git a/deps.nix b/deps.nix new file mode 100644 index 0000000..2fccce4 --- /dev/null +++ b/deps.nix @@ -0,0 +1,13 @@ +{ sources ? import ./nix/sources.nix }: +let + pkgs = import sources.nixpkgs {}; + easy-dhall-nix = import sources.easy-dhall-nix { inherit pkgs; }; + easy-purescript-nix = import sources.easy-purescript-nix { inherit pkgs; }; +in + { + inherit pkgs; + dhall-json = easy-dhall-nix.dhall-json-simple; + spago = easy-purescript-nix.spago; + purescript = easy-purescript-nix.purescript; + nodejs = pkgs.nodejs-10_x; +} diff --git a/mkbin.nix b/mkbin.nix index decb3db..32d2186 100644 --- a/mkbin.nix +++ b/mkbin.nix @@ -4,7 +4,7 @@ # nix-shell mkbin.nix # -{ pkgs ? import {} +{ pkgs ? (import ./deps.nix {}).pkgs , nodejs ? pkgs.nodejs-10_x }: diff --git a/nix/sources.json b/nix/sources.json new file mode 100644 index 0000000..98026de --- /dev/null +++ b/nix/sources.json @@ -0,0 +1,26 @@ +{ + "easy-dhall-nix": { + "branch": "master", + "description": "Derivations for easily downloading Dhall binaries and putting them to use.", + "owner": "justinwoo", + "repo": "easy-dhall-nix", + "sha256": "1y2x15v8a679vlpxazjpibfwajp6zph60f8wjcm4xflbvazk0dx7", + "url": "https://github.com/justinwoo/easy-dhall-nix/archive/eae7f64c4d6c70681e5a56c84198236930ba425e.tar.gz" + }, + "easy-purescript-nix": { + "branch": "master", + "description": "Easy PureScript (and other tools) with Nix", + "owner": "justinwoo", + "repo": "easy-purescript-nix", + "sha256": "1ly3bm6i1viw6d64gi1zfiwdvjncm3963rj59320cr15na5bzjri", + "url": "https://github.com/justinwoo/easy-purescript-nix/archive/860a95cb9e1ebdf574cede2b4fcb0f66eac77242.tar.gz" + }, + "nixpkgs": { + "branch": "release-20.03", + "description": "Nix Packages collection", + "owner": "NixOS", + "repo": "nixpkgs", + "sha256": "0zi54vbfi6i6i5hdd4v0l144y1c8rg6hq6818jjbbcnm182ygyfa", + "url": "https://github.com/NixOS/nixpkgs/archive/929768261a3ede470eafb58d5b819e1a848aa8bf.tar.gz" + } +} diff --git a/nix/sources.nix b/nix/sources.nix new file mode 100644 index 0000000..7382d21 --- /dev/null +++ b/nix/sources.nix @@ -0,0 +1,8 @@ +let + fetch = arg@{url, sha256}: builtins.fetchTarball arg; + + json = builtins.fromJSON (builtins.readFile ./sources.json); + + sources = builtins.mapAttrs (_: v: fetch { inherit (v) url sha256; }) json; + +in sources diff --git a/test/tests.bash b/test/tests.bash index 0b07efc..0f45308 100755 --- a/test/tests.bash +++ b/test/tests.bash @@ -3,10 +3,18 @@ set -e -spago2nix -spago2nix generate 8 -spago2nix install -spago2nix build -rm -rf output -spago2nix build-nix -nix-build build-project.nix +function run () { + echo "$ $@" + "$@" +} + +run spago2nix +run spago2nix generate 8 +run spago2nix install \ + --arg pkgs '(import ./deps.nix {}).pkgs' +run spago2nix build \ + --arg pkgs '(import ./deps.nix {}).pkgs' +run rm -rf output +run spago2nix build-nix \ + --arg pkgs '(import ./deps.nix {}).pkgs' +run nix-build build-project.nix