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

add flake-compat and a default overlay for consumption in non-flake projects #11

Open
wants to merge 6 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ test/**/.pnp.loader.mjs
**/.yarn/unplugged
**/.yarn/install-state.gz
tsconfig.tsbuildinfo
test/workspace/.yarn/cache
10 changes: 10 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).defaultNix
17 changes: 17 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 24 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,43 @@
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixos-22.05;
utils.url = github:numtide/flake-utils;
flake-compat ={
url = "github:edolstra/flake-compat";
flake = false;
};
};

outputs = inputs@{ self, nixpkgs, utils, ... }:
utils.lib.eachDefaultSystem (system:
let
overlay = final: prev: {
yarnBerry = final.callPackage ./yarn.nix {};
yarn-plugin-yarnpnp2nix = final.callPackage ./yarnPlugin.nix {};
yarnpnp2nixLib = import ./lib/mkYarnPackage.nix { defaultPkgs = final; lib = final.lib; };
};
in (utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
yarnBerry = prev.callPackage ./yarn.nix {};
})
];
overlays = [overlay];
};
in
rec {
packages = {
yarn-plugin = pkgs.callPackage ./yarnPlugin.nix {};
};
lib = {
mkYarnPackagesFromManifest = (import ./lib/mkYarnPackage.nix { defaultPkgs = pkgs; lib = pkgs.lib; }).mkYarnPackagesFromManifest;
yarn-plugin = pkgs.yarn-plugin-yarnpnp2nix;
yarnBerry = pkgs.yarnBerry;
yarnpnp2nix-test = pkgs.writeShellApplication {
name = "yarnpnp2nix-test";
runtimeInputs = [ pkgs.jq ];
text = builtins.readFile ./runTests.sh;
};
};
lib = pkgs.yarnpnp2nixLib;
devShell = import ./shell.nix {
inherit pkgs;
};
}
);
))
//
{ overlays.default = overlay; }
;
}
14 changes: 7 additions & 7 deletions runTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ pushd test

nix eval --json .#packages.aarch64-darwin.testa.transitiveRuntimePackages

nix build -L .#packages.$system.testb
nix build -L ".#packages.$system.testb"
./result/bin/testb

nix build -L .#packages.$system.testa
nix build -L ".#packages.$system.testa"
./result/bin/testa-peer-test

nix build -L .#packages.$system.testb.package
nix build -L ".#packages.$system.testb.package"
testbPackage=$(realpath ./result)/node_modules/testb

nix build -L .#packages.$system.testb.shellRuntimeEnvironment
nix build -L ".#packages.$system.testb.shellRuntimeEnvironment"
runShellEnvironmentTest=$(realpath ./result)

pushd $testbPackage
$runShellEnvironmentTest/bin/testa-test
pushd "$testbPackage"
"$runShellEnvironmentTest/bin/testa-test"
popd

nix develop .#packages.$system.testb -c bash <<EOF
nix develop ".#packages.$system.testb" -c bash <<EOF
cd $testbPackage
testa-test
EOF
Expand Down
23 changes: 20 additions & 3 deletions test/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.