mirror of
https://github.com/nmattia/niv.git
synced 2024-09-18 19:07:19 +03:00
Restructure Nix dirs
This commit is contained in:
parent
8d4c790464
commit
5e9d9b0695
4
Main.hs
4
Main.hs
@ -623,8 +623,8 @@ pathShellNix = "shell.nix"
|
||||
-- | Simple shell that loads @niv@
|
||||
initShellNixContent :: String
|
||||
initShellNixContent = [s|
|
||||
let pkgs = import ./nix;
|
||||
in pkgs.mkShell
|
||||
with { pkgs = import ./nix {}; };
|
||||
pkgs.mkShell
|
||||
{ buildInputs = [ pkgs.niv ];
|
||||
}
|
||||
|]
|
||||
|
@ -1,2 +1,2 @@
|
||||
with { pkgs = import ./nix {}; };
|
||||
{ inherit (pkgs) niv readme readme-test ; }
|
||||
{ pkgs ? import ./nix {} }:
|
||||
pkgs.callPackage ./nix/packages.nix {}
|
||||
|
@ -1,3 +1,14 @@
|
||||
{ sources ? import ./sources.nix }:
|
||||
import sources.nixpkgs
|
||||
{ overlays = import ./overlay.nix { inherit sources; } ; config = {}; }
|
||||
{ overlays =
|
||||
[
|
||||
# Snack
|
||||
(self: super:
|
||||
{
|
||||
snack-exe = (import sources.snack).snack-exe;
|
||||
snack-lib = (import sources.snack).snack-lib;
|
||||
}
|
||||
)
|
||||
];
|
||||
config = {};
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
{ sources ? import ./sources.nix }:
|
||||
[
|
||||
|
||||
# Snack
|
||||
(self: super:
|
||||
{
|
||||
snack-exe = (import sources.snack).snack-exe;
|
||||
snack-lib = (import sources.snack).snack-lib;
|
||||
}
|
||||
)
|
||||
|
||||
# Built niv
|
||||
(self: super:
|
||||
{ niv = super.snack-lib.executable ../package.yaml ; }
|
||||
)
|
||||
|
||||
# README generation
|
||||
(self: super:
|
||||
rec { readme = self.writeText "README.md"
|
||||
(with
|
||||
{ template = builtins.readFile ../README.tpl.md;
|
||||
niv_help = builtins.readFile
|
||||
(self.runCommand "niv_help" { buildInputs = [ self.niv ]; }
|
||||
"niv --help > $out"
|
||||
);
|
||||
niv_add_help = builtins.readFile
|
||||
(self.runCommand "niv_add_help" { buildInputs = [ self.niv ]; }
|
||||
"niv add --help > $out"
|
||||
);
|
||||
niv_update_help = builtins.readFile
|
||||
(self.runCommand "niv_update_help" { buildInputs = [ self.niv ]; }
|
||||
"niv update --help > $out"
|
||||
);
|
||||
niv_drop_help = builtins.readFile
|
||||
(self.runCommand "niv_drop_help" { buildInputs = [ self.niv ]; }
|
||||
"niv drop --help > $out"
|
||||
);
|
||||
};
|
||||
self.lib.replaceStrings
|
||||
[
|
||||
"replace_niv_help"
|
||||
"replace_niv_add_help"
|
||||
"replace_niv_update_help"
|
||||
"replace_niv_drop_help"
|
||||
]
|
||||
[ niv_help niv_add_help niv_update_help niv_drop_help ]
|
||||
template
|
||||
);
|
||||
readme-test = self.runCommand "README-test" {}
|
||||
"diff ${../README.md} ${readme} && echo dummy > $out";
|
||||
}
|
||||
)
|
||||
]
|
40
nix/packages.nix
Normal file
40
nix/packages.nix
Normal file
@ -0,0 +1,40 @@
|
||||
{ writeText
|
||||
, runCommand
|
||||
, lib
|
||||
, snack-lib
|
||||
}:
|
||||
rec
|
||||
{ niv = snack-lib.executable ../package.yaml;
|
||||
readme = writeText "README.md"
|
||||
(with
|
||||
{ template = builtins.readFile ../README.tpl.md;
|
||||
niv_help = builtins.readFile
|
||||
(runCommand "niv_help" { buildInputs = [ niv ]; }
|
||||
"niv --help > $out"
|
||||
);
|
||||
niv_add_help = builtins.readFile
|
||||
(runCommand "niv_add_help" { buildInputs = [ niv ]; }
|
||||
"niv add --help > $out"
|
||||
);
|
||||
niv_update_help = builtins.readFile
|
||||
(runCommand "niv_update_help" { buildInputs = [ niv ]; }
|
||||
"niv update --help > $out"
|
||||
);
|
||||
niv_drop_help = builtins.readFile
|
||||
(runCommand "niv_drop_help" { buildInputs = [ niv ]; }
|
||||
"niv drop --help > $out"
|
||||
);
|
||||
};
|
||||
lib.replaceStrings
|
||||
[
|
||||
"replace_niv_help"
|
||||
"replace_niv_add_help"
|
||||
"replace_niv_update_help"
|
||||
"replace_niv_drop_help"
|
||||
]
|
||||
[ niv_help niv_add_help niv_update_help niv_drop_help ]
|
||||
template
|
||||
);
|
||||
readme-test = runCommand "README-test" {}
|
||||
"diff ${../README.md} ${readme} && echo dummy > $out";
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
# A record, from name to path, of the third-party packages
|
||||
with
|
||||
{
|
||||
versions = builtins.fromJSON (builtins.readFile ./versions.json);
|
||||
specs = builtins.fromJSON (builtins.readFile ./specs.json);
|
||||
|
||||
# fetchTarball version that is compatible between all the versions of Nix
|
||||
# fetchTarball version that is compatible between all the specs of Nix
|
||||
fetchTarball =
|
||||
{ url, sha256 }:
|
||||
if builtins.lessThan builtins.nixVersion "1.12" then
|
||||
@ -19,11 +19,11 @@ with
|
||||
mapAttrs (_: spec:
|
||||
if builtins.hasAttr "outPath" spec
|
||||
then abort
|
||||
"The values in versions.json should not have an 'outPath' attribute"
|
||||
"The values in specs.json should not have an 'outPath' attribute"
|
||||
else
|
||||
if builtins.hasAttr "url" spec && builtins.hasAttr "sha256" spec
|
||||
then
|
||||
spec //
|
||||
{ outPath = fetchTarball { inherit (spec) url sha256; } ; }
|
||||
else spec
|
||||
) versions
|
||||
) specs
|
||||
|
@ -4,8 +4,16 @@
|
||||
#!nix-shell -p nix
|
||||
#!nix-shell --pure
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
export NIX_PATH="nixpkgs=./nix"
|
||||
|
||||
echo "Building"
|
||||
|
||||
nix build --no-link
|
||||
|
||||
echo "Testing shell"
|
||||
|
||||
nix-shell --run "echo -n"
|
||||
|
||||
echo "all good"
|
||||
|
Loading…
Reference in New Issue
Block a user