mirror of
https://github.com/nmattia/snack.git
synced 2024-09-11 11:55:36 +03:00
Add snack run and fixup script
This commit is contained in:
parent
ddfe7782f0
commit
13c120327c
42
default.nix
42
default.nix
@ -1,16 +1,48 @@
|
||||
{ pkgs ? import <nixpkgs> {} }:
|
||||
{ pkgs ? import ./nix {} }:
|
||||
|
||||
{ snack-lib = import ./snack/default.nix { inherit pkgs; };
|
||||
snack-exe = pkgs.writeScriptBin "snack"
|
||||
''
|
||||
set -e
|
||||
case $1 in
|
||||
set -euo pipefail
|
||||
|
||||
SNACK_NIX=snack.nix
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
key="$1"
|
||||
|
||||
case $key in
|
||||
-f|--snack-nix)
|
||||
SNACK_NIX="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
run|build|ghci)
|
||||
COMMAND="$1"
|
||||
shift # past argument
|
||||
;;
|
||||
*) # unknown option
|
||||
echo "unknown option: $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "snack nix: $SNACK_NIX"
|
||||
echo "command: $COMMAND"
|
||||
|
||||
case $COMMAND in
|
||||
build)
|
||||
${pkgs.nix}/bin/nix-build snack.nix
|
||||
${pkgs.nix}/bin/nix-build --no-out-link -A build $SNACK_NIX
|
||||
;;
|
||||
ghci)
|
||||
res=$(${pkgs.nix}/bin/nix-build -A ghci snack.nix)
|
||||
res=$(${pkgs.nix}/bin/nix-build --no-out-link -A ghci $SNACK_NIX)
|
||||
$res/bin/ghci
|
||||
;;
|
||||
run)
|
||||
res=$(${pkgs.nix}/bin/nix-build --no-out-link -A build $SNACK_NIX)
|
||||
echo "running $res"
|
||||
$res/out
|
||||
;;
|
||||
esac
|
||||
'';
|
||||
}
|
||||
|
@ -2,19 +2,6 @@
|
||||
import (import nixpkgs) {
|
||||
config = { allowUnfree = true; };
|
||||
overlays = [
|
||||
(self: super: { snack-lib = import ../snack {};} )
|
||||
(self: super: { snack-lib-with = extra: import ../snack extra;} )
|
||||
(self: super: { snack = self.writeScriptBin "snack"
|
||||
''
|
||||
set -e
|
||||
case $1 in
|
||||
build)
|
||||
${self.nix}/bin/nix-build snack.nix
|
||||
;;
|
||||
ghci)
|
||||
res=$(${self.nix}/bin/nix-build -A ghci snack.nix)
|
||||
$res/bin/ghci
|
||||
esac
|
||||
''; })
|
||||
(self: super: { snack = import ../. {}; })
|
||||
];
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash
|
||||
#!nix-shell -I nixpkgs=./nix
|
||||
#!nix-shell -p snack
|
||||
#!nix-shell -p snack.snack-exe
|
||||
#!nix-shell --pure
|
||||
# vim: ft=sh sw=2 et
|
||||
|
||||
@ -15,8 +15,8 @@ pushd tests/template-haskell
|
||||
snack build
|
||||
popd
|
||||
|
||||
pushd tests/template-haskell-2/code
|
||||
snack build
|
||||
pushd tests/template-haskell-2
|
||||
snack build -f code/snack.nix
|
||||
popd
|
||||
|
||||
pushd tests/template-haskell-3
|
||||
|
@ -1,6 +1,6 @@
|
||||
let
|
||||
pkgs = import ../../nix {};
|
||||
snack = pkgs.snack-lib;
|
||||
snack = pkgs.snack.snack-lib;
|
||||
in
|
||||
snack.executable
|
||||
{ main = "Foo";
|
||||
|
@ -1,6 +1,6 @@
|
||||
let
|
||||
pkgs = import ../../../nix {};
|
||||
snack = pkgs.snack-lib;
|
||||
snack = pkgs.snack.snack-lib;
|
||||
in
|
||||
snack.executable
|
||||
{ main = "Main";
|
||||
|
@ -1,13 +1,11 @@
|
||||
let
|
||||
pkgs = import ../../nix {};
|
||||
snack = pkgs.snack-lib;
|
||||
snack = pkgs.snack.snack-lib;
|
||||
in
|
||||
snack.executable
|
||||
{ main = "Main";
|
||||
src = ./.;
|
||||
dependencies = ["file-embed"];
|
||||
extra-files =
|
||||
# "assets/foo.txt", which is just
|
||||
# filterSource (p == "assets/foo.txt") ./.
|
||||
(modName: if modName == "Main" then [ "assets/foo.txt" ] else []);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
let
|
||||
pkgs = import ../../nix {};
|
||||
snack = pkgs.snack-lib;
|
||||
snack = pkgs.snack.snack-lib;
|
||||
in
|
||||
snack.executable
|
||||
{ main = "Main";
|
||||
|
Loading…
Reference in New Issue
Block a user