mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-09-11 22:37:18 +03:00
fix(spago): fix flake inputs
This commit is contained in:
parent
e4a9da41ad
commit
03b1e05f7b
@ -1,7 +1,4 @@
|
||||
{
|
||||
dream2nix,
|
||||
...
|
||||
}: {
|
||||
{dream2nix, ...}: {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.WIP-spago
|
||||
];
|
||||
|
@ -1,5 +1,5 @@
|
||||
# This file provides backward compatibility to nix < 2.4 clients
|
||||
let
|
||||
inputs: let
|
||||
flake =
|
||||
import
|
||||
(
|
||||
@ -13,4 +13,4 @@ let
|
||||
)
|
||||
{src = ./.;};
|
||||
in
|
||||
flake.defaultNix
|
||||
flake.defaultNix.overrideInputs inputs
|
||||
|
@ -1,11 +1,18 @@
|
||||
{lib, dream2nix, config, packageSets, ...}:
|
||||
let
|
||||
{
|
||||
lib,
|
||||
dream2nix,
|
||||
config,
|
||||
packageSets,
|
||||
...
|
||||
}: let
|
||||
l = lib // builtins;
|
||||
|
||||
purescript-overlay = builtins.getFlake "github:thomashoneyman/purescript-overlay/dbf63923b2d7a8ed03e962db9f450e6fa61fb526";
|
||||
depsFlake = import ../../default.nix {
|
||||
nixpkgs = packageSets.nixpkgs.path;
|
||||
};
|
||||
|
||||
purescript-overlay = depsFlake.inputs.purescript-overlay;
|
||||
inherit (purescript-overlay.packages.${config.deps.stdenv.system}) purs spago-unstable;
|
||||
# FIXME wait fix by Dave and then remove lines above
|
||||
# inherit (dream2nix.inputs.purescript-overlay.packages.${config.deps.stdenv.system}) purs spago-unstable;
|
||||
|
||||
registry-index = config.deps.fetchFromGitHub {
|
||||
owner = "purescript";
|
||||
@ -20,7 +27,7 @@ let
|
||||
rev = "cf70a36e1233f71bd4a39d516a76dd25129184e3";
|
||||
hash = "sha256-h7wcsL8ubXSK7JAm+5UFq+9b5FDiRyz5F/mzRsaHJvI=";
|
||||
};
|
||||
|
||||
|
||||
writers = import ../../../pkgs/writers {
|
||||
inherit lib;
|
||||
inherit
|
||||
@ -35,25 +42,25 @@ let
|
||||
};
|
||||
|
||||
cfg = config.spago;
|
||||
|
||||
|
||||
lock = config.lock.content.spago-lock;
|
||||
|
||||
mkTarball = depName: config.deps.runCommand "${depName}-tarball" {} ''
|
||||
mkdir ${depName}-${l.removePrefix "v" lock.${depName}.version}
|
||||
cd ${depName}-${l.removePrefix "v" lock.${depName}.version}
|
||||
cp -r ${cfg.sources.${depName}}/* .
|
||||
cd ..
|
||||
tar -cvzf $out .
|
||||
'';
|
||||
|
||||
mkTarball = depName:
|
||||
config.deps.runCommand "${depName}-tarball" {} ''
|
||||
mkdir ${depName}-${l.removePrefix "v" lock.${depName}.version}
|
||||
cd ${depName}-${l.removePrefix "v" lock.${depName}.version}
|
||||
cp -r ${cfg.sources.${depName}}/* .
|
||||
cd ..
|
||||
tar -cvzf $out .
|
||||
'';
|
||||
|
||||
installSource = depName: dep: ''
|
||||
ln -s ${dep} .spago/packages/${depName}-${lock.${depName}.version}
|
||||
mkdir -p $HOME/.cache/spago-nodejs/packages/${depName}
|
||||
mkdir -p $HOME/.cache/spago-nodejs/packages/${depName}
|
||||
cp ${mkTarball depName} $HOME/.cache/spago-nodejs/packages/${depName}/${l.removePrefix "v" lock.${depName}.version}.tar.gz
|
||||
'';
|
||||
|
||||
installSources = l.mapAttrsToList installSource cfg.sources;
|
||||
|
||||
in {
|
||||
imports = [
|
||||
dream2nix.modules.dream2nix.core
|
||||
@ -61,10 +68,12 @@ in {
|
||||
./interface.nix
|
||||
];
|
||||
|
||||
spago.sources = l.mapAttrs (depName: dep: builtins.fetchGit (l.trace (builtins.toJSON dep) {
|
||||
inherit (dep) rev;
|
||||
url = dep.repo;
|
||||
})) config.lock.content.spago-lock;
|
||||
spago.sources = l.mapAttrs (depName: dep:
|
||||
builtins.fetchGit {
|
||||
inherit (dep) rev;
|
||||
url = dep.repo;
|
||||
})
|
||||
config.lock.content.spago-lock;
|
||||
|
||||
mkDerivation = {
|
||||
nativeBuildInputs = [
|
||||
@ -87,51 +96,52 @@ in {
|
||||
${toString installSources}
|
||||
spago bundle --verbose
|
||||
OUTFILE="$(yq -r '.package.bundle.outfile // "index.js"' spago.yaml)"
|
||||
mkdir -p $out/bin
|
||||
cp "$OUTFILE" "$out/bin/$OUTFILE"
|
||||
mkdir -p $out/bin
|
||||
cp "$OUTFILE" "$out/bin/$OUTFILE"
|
||||
'';
|
||||
};
|
||||
|
||||
lock.fields.spago-lock.script = writers.writePureShellScript [
|
||||
config.deps.coreutils
|
||||
config.deps.curl
|
||||
config.deps.gnutar
|
||||
config.deps.gzip
|
||||
config.deps.yq-go
|
||||
config.deps.python3
|
||||
config.deps.git
|
||||
]
|
||||
''
|
||||
set -euo pipefail
|
||||
mkdir $TMPDIR/package-sets
|
||||
cd $TMPDIR/package-sets
|
||||
curl -fL https://github.com/purescript/package-sets/archive/refs/heads/master.tar.gz | tar xz --strip-components=1
|
||||
yq -o=json < ${config.spago.spagoYamlFile} > spago.json
|
||||
python3 ${./lock.py}
|
||||
'';
|
||||
|
||||
deps = {nixpkgs, ...}:
|
||||
l.mapAttrs (_: l.mkDefault) {
|
||||
inherit
|
||||
(nixpkgs)
|
||||
stdenv
|
||||
coreutils
|
||||
curl
|
||||
writeScript
|
||||
writeScriptBin
|
||||
bash
|
||||
path
|
||||
gawk
|
||||
gnutar
|
||||
gzip
|
||||
yq-go
|
||||
python3
|
||||
git
|
||||
esbuild # used by spago bundle
|
||||
fetchFromGitHub
|
||||
breakpointHook
|
||||
runCommand
|
||||
nodejs
|
||||
;
|
||||
};
|
||||
lock.fields.spago-lock.script =
|
||||
writers.writePureShellScript [
|
||||
config.deps.coreutils
|
||||
config.deps.curl
|
||||
config.deps.gnutar
|
||||
config.deps.gzip
|
||||
config.deps.yq-go
|
||||
config.deps.python3
|
||||
config.deps.git
|
||||
]
|
||||
''
|
||||
set -euo pipefail
|
||||
mkdir $TMPDIR/package-sets
|
||||
cd $TMPDIR/package-sets
|
||||
curl -fL https://github.com/purescript/package-sets/archive/refs/heads/master.tar.gz | tar xz --strip-components=1
|
||||
yq -o=json < ${config.spago.spagoYamlFile} > spago.json
|
||||
python3 ${./lock.py}
|
||||
'';
|
||||
|
||||
deps = {nixpkgs, ...}:
|
||||
l.mapAttrs (_: l.mkDefault) {
|
||||
inherit
|
||||
(nixpkgs)
|
||||
stdenv
|
||||
coreutils
|
||||
curl
|
||||
writeScript
|
||||
writeScriptBin
|
||||
bash
|
||||
path
|
||||
gawk
|
||||
gnutar
|
||||
gzip
|
||||
yq-go
|
||||
python3
|
||||
git
|
||||
esbuild # used by spago bundle
|
||||
fetchFromGitHub
|
||||
breakpointHook
|
||||
runCommand
|
||||
nodejs
|
||||
;
|
||||
};
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import os
|
||||
import multiprocessing
|
||||
from multiprocessing.pool import ThreadPool
|
||||
|
||||
with open('spago.json', 'r') as spagoFile, open('packages.json', 'r') as packagesFile:
|
||||
with open("spago.json", "r") as spagoFile, open("packages.json", "r") as packagesFile:
|
||||
spago = json.load(spagoFile)
|
||||
packagesSet = json.load(packagesFile)
|
||||
|
||||
@ -13,6 +13,7 @@ checked = set()
|
||||
|
||||
closure = set(dependencies)
|
||||
|
||||
|
||||
def getDeps(deps):
|
||||
for dep in deps.copy():
|
||||
if dep in checked:
|
||||
@ -21,21 +22,25 @@ def getDeps(deps):
|
||||
closure.update(getDeps(set(packagesSet[dep]["dependencies"])))
|
||||
return deps
|
||||
|
||||
|
||||
|
||||
getDeps(set(dependencies))
|
||||
|
||||
lock = {}
|
||||
|
||||
|
||||
def getSource(depName):
|
||||
dep = packagesSet[depName]
|
||||
repo = dep["repo"]
|
||||
version = dep["version"]
|
||||
rev = subprocess.run(["git", "ls-remote", repo, version], text=True, capture_output=True).stdout.split()[0]
|
||||
rev = subprocess.run(
|
||||
["git", "ls-remote", repo, version], text=True, capture_output=True
|
||||
).stdout.split()[0]
|
||||
print(f"{repo}/{version}: {rev}")
|
||||
lock[depName] = dep
|
||||
lock[depName]["rev"] = rev
|
||||
|
||||
with ThreadPool(processes=multiprocessing.cpu_count()*2) as pool:
|
||||
|
||||
with ThreadPool(processes=multiprocessing.cpu_count() * 2) as pool:
|
||||
pool.map_async(getSource, closure)
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
@ -7,7 +7,7 @@
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
modulesFlake = import "${self}/modules";
|
||||
modulesFlake = import "${self}/modules" {};
|
||||
inputs = lib.mapAttrs (name: input: "${input.outPath}") modulesFlake.inputs;
|
||||
inputsFile = builtins.toFile "inputs.json" (builtins.toJSON inputs);
|
||||
in
|
||||
|
@ -3,31 +3,32 @@
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1673956053,
|
||||
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
|
||||
"owner": "edolstra",
|
||||
"lastModified": 1695612854,
|
||||
"narHash": "sha256-QPe1fENhAB4l/N04FulgItq1rfcpQMttGZzikV7h3iI=",
|
||||
"owner": "nix-community",
|
||||
"repo": "flake-compat",
|
||||
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
|
||||
"rev": "ad8d6af6aa8a14851a60bd00927f42b9798544ea",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"owner": "nix-community",
|
||||
"ref": "pull/4/head",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1695830400,
|
||||
"narHash": "sha256-gToZXQVr0G/1WriO83olnqrLSHF2Jb8BPcmCt497ro0=",
|
||||
"lastModified": 1695837737,
|
||||
"narHash": "sha256-KcqmJ5hNacLuE7fkz5586kp/vt4NLo6+Prq3DMgrxpQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2",
|
||||
"rev": "517501bcf14ae6ec47efd6a17dda0ca8e6d866f9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
@ -40,11 +41,11 @@
|
||||
"slimlock": "slimlock"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1695569752,
|
||||
"narHash": "sha256-zjfsJfHT/YedX2sAgK9g6X8XTsRH5Cr18hS1iBFvb+w=",
|
||||
"lastModified": 1696022621,
|
||||
"narHash": "sha256-eMjFmsj2G1E0Q5XiibUNgFjTiSz0GxIeSSzzVdoN730=",
|
||||
"owner": "thomashoneyman",
|
||||
"repo": "purescript-overlay",
|
||||
"rev": "dbf63923b2d7a8ed03e962db9f450e6fa61fb526",
|
||||
"rev": "047c7933abd6da8aa239904422e22d190ce55ead",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -2,11 +2,16 @@
|
||||
description = "(modules only) dream2nix: Automate reproducible packaging for various language ecosystems";
|
||||
|
||||
inputs = {
|
||||
flake-compat.url = "github:edolstra/flake-compat";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
flake-compat.url = "github:nix-community/flake-compat/pull/4/head";
|
||||
flake-compat.flake = false;
|
||||
|
||||
pyproject-nix.url = "github:adisbladis/pyproject.nix";
|
||||
pyproject-nix.flake = false;
|
||||
|
||||
purescript-overlay.url = "github:thomashoneyman/purescript-overlay";
|
||||
purescript-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = _: let
|
||||
|
Loading…
Reference in New Issue
Block a user