mirror of
https://github.com/nmattia/niv.git
synced 2024-11-22 22:10:46 +03:00
Merge pull request #41 from nmattia/nm-nix-cleanup
Replace snack with cabal
This commit is contained in:
commit
130ac83460
@ -23,6 +23,12 @@ jobs:
|
||||
echo "keep-outputs = true" | sudo tee -a /etc/nix/nix.conf
|
||||
echo "keep-derivations = true" | sudo tee -a /etc/nix/nix.conf
|
||||
|
||||
# Set a new TMP because /run/user is (1) pretty small and (2)
|
||||
# mounted with noexec
|
||||
new_tmp=$HOME/tmp
|
||||
mkdir -p $new_tmp
|
||||
echo "export TMPDIR=$new_tmp" >> $BASH_ENV
|
||||
|
||||
# Builds everything from scratch on master. On a branch the branch's
|
||||
# cache is used if it exists, otherwise the latest cache generated from
|
||||
# master is used.
|
||||
|
@ -16,10 +16,7 @@ $ nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master
|
||||
Inside the provided nix shell:
|
||||
|
||||
``` bash
|
||||
$ # GHCi:
|
||||
$ snack ghci
|
||||
$ # run:
|
||||
$ snack run -- <args>
|
||||
$ repl
|
||||
```
|
||||
|
||||
Run the test suite with this command:
|
||||
|
@ -16,10 +16,7 @@ $ nix-env -iA niv -f https://github.com/nmattia/niv/tarball/master
|
||||
Inside the provided nix shell:
|
||||
|
||||
``` bash
|
||||
$ # GHCi:
|
||||
$ snack ghci
|
||||
$ # run:
|
||||
$ snack run -- <args>
|
||||
$ repl
|
||||
```
|
||||
|
||||
Run the test suite with this command:
|
||||
|
@ -6,8 +6,6 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE ViewPatterns #-}
|
||||
|
||||
module Main (main) where
|
||||
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Control.Monad.State
|
59
default.nix
59
default.nix
@ -1,2 +1,59 @@
|
||||
{ pkgs ? import ./nix {} }:
|
||||
pkgs.callPackage ./nix/packages.nix {}
|
||||
with rec
|
||||
{ niv-source = pkgs.lib.sourceByRegex ./.
|
||||
[ "^package.yaml$"
|
||||
"^app.*$"
|
||||
"^README.md$"
|
||||
];
|
||||
haskellPackages = pkgs.haskellPackages.override
|
||||
{ overrides = _: haskellPackages:
|
||||
{ niv = haskellPackages.callCabal2nix "niv" niv-source {}; };
|
||||
};
|
||||
|
||||
niv-devshell = haskellPackages.shellFor
|
||||
{ packages = (ps: [ ps.niv ]);
|
||||
shellHook =
|
||||
''
|
||||
repl() {
|
||||
ghci Main.hs
|
||||
}
|
||||
|
||||
echo "To start a REPL session, run:"
|
||||
echo " > repl"
|
||||
'';
|
||||
};
|
||||
};
|
||||
rec
|
||||
{ inherit niv-source niv-devshell;
|
||||
inherit (haskellPackages) niv;
|
||||
readme = pkgs.writeText "README.md"
|
||||
(with
|
||||
{ template = builtins.readFile ./README.tpl.md;
|
||||
niv_help = builtins.readFile
|
||||
(pkgs.runCommand "niv_help" { buildInputs = [ niv ]; }
|
||||
"niv --help > $out"
|
||||
);
|
||||
niv_cmd_help = cmd: builtins.readFile
|
||||
(pkgs.runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; }
|
||||
"niv ${cmd} --help > $out"
|
||||
);
|
||||
cmds = [ "add" "update" "drop" "init" "show" ];
|
||||
};
|
||||
pkgs.lib.replaceStrings
|
||||
([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds))
|
||||
([ niv_help ] ++ (map niv_cmd_help cmds))
|
||||
template
|
||||
);
|
||||
readme-test = pkgs.runCommand "README-test" {}
|
||||
''
|
||||
err() {
|
||||
echo
|
||||
echo -e "\e[31mERR\e[0m: README.md out of date"
|
||||
echo -e "please run \e[1m./script/gen\e[0m"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
diff ${./README.md} ${readme} && echo dummy > $out || err ;
|
||||
'';
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
{ 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_cmd_help = cmd: builtins.readFile
|
||||
(runCommand "niv_${cmd}_help" { buildInputs = [ niv ]; }
|
||||
"niv ${cmd} --help > $out"
|
||||
);
|
||||
cmds = [ "add" "update" "drop" "init" "show" ];
|
||||
};
|
||||
lib.replaceStrings
|
||||
([ "replace_niv_help" ] ++ (map (cmd: "replace_niv_${cmd}_help") cmds))
|
||||
([ niv_help ] ++ (map niv_cmd_help cmds))
|
||||
template
|
||||
);
|
||||
readme-test = runCommand "README-test" {}
|
||||
''
|
||||
err() {
|
||||
echo
|
||||
echo -e "\e[31mERR\e[0m: README.md out of date"
|
||||
echo -e "please run \e[1m./script/gen\e[0m"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
diff ${../README.md} ${readme} && echo dummy > $out || err ;
|
||||
'';
|
||||
}
|
@ -1,15 +1,4 @@
|
||||
{
|
||||
"snack": {
|
||||
"homepage": "",
|
||||
"url": "https://github.com/nmattia/snack/archive/7b90144a01fff7e5eeb520a6b774377f75e44205.tar.gz",
|
||||
"owner": "nmattia",
|
||||
"branch": "master",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
|
||||
"repo": "snack",
|
||||
"sha256": "0p0bldlr83i4bigsv0ygnn7q0lv25hkjd5n4nm1vlvwm9cp8n5dn",
|
||||
"description": "Nix-based incremental build tool for Haskell projects",
|
||||
"rev": "7b90144a01fff7e5eeb520a6b774377f75e44205"
|
||||
},
|
||||
"nixpkgs": {
|
||||
"url": "https://github.com/NixOS/nixpkgs-channels/archive/8e70d4bd7d5e1c137006fe483d8d116311694bc2.tar.gz",
|
||||
"owner": "NixOS",
|
||||
|
10
package.yaml
10
package.yaml
@ -1,13 +1,19 @@
|
||||
name: niv
|
||||
|
||||
license: MIT
|
||||
|
||||
ghc-options:
|
||||
- -Wall
|
||||
- -Werror
|
||||
|
||||
executable:
|
||||
source-dirs: . # remove when https://github.com/nmattia/snack/pull/96 is merged
|
||||
main: Main.hs
|
||||
main: app/Niv.hs
|
||||
dependencies:
|
||||
- base
|
||||
- hashable
|
||||
- process
|
||||
- text
|
||||
- bytestring
|
||||
- aeson
|
||||
- aeson-pretty
|
||||
- directory
|
||||
|
Loading…
Reference in New Issue
Block a user