Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix pin deps #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion build-project.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? (import ./deps.nix {}).pkgs }:

let
easy-ps = import (
Expand Down
16 changes: 3 additions & 13 deletions ci.nix
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{ pkgs ? import <nixpkgs> {} }:
{ 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 ];
}
73 changes: 24 additions & 49 deletions default.nix
Original file line number Diff line number Diff line change
@@ -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 <nixpkgs> {}
, 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
]}
'';
}
13 changes: 13 additions & 0 deletions deps.nix
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion mkbin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# nix-shell mkbin.nix
#

{ pkgs ? import <nixpkgs> {}
{ pkgs ? (import ./deps.nix {}).pkgs
, nodejs ? pkgs.nodejs-10_x
}:

Expand Down
26 changes: 26 additions & 0 deletions nix/sources.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
8 changes: 8 additions & 0 deletions nix/sources.nix
Original file line number Diff line number Diff line change
@@ -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
22 changes: 15 additions & 7 deletions test/tests.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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