Nix build harness
This commit is contained in:
parent
3554348dca
commit
7998bacc15
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,3 +19,6 @@ cabal.sandbox.config
|
|||||||
*~
|
*~
|
||||||
\#*
|
\#*
|
||||||
uniworx.cabal
|
uniworx.cabal
|
||||||
|
uniworx.nix
|
||||||
|
.gup/
|
||||||
|
.dbsettings.yml
|
||||||
6
default.nix
Normal file
6
default.nix
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
argumentPackages@{ ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
defaultPackages = (import <nixpkgs> {}).haskellPackages;
|
||||||
|
haskellPackages = defaultPackages // argumentPackages;
|
||||||
|
in import ./uniworx.nix { inherit (haskellPackages) callPackage; }
|
||||||
4
gup/Gupfile
Normal file
4
gup/Gupfile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
cabal2nix.gup:
|
||||||
|
*.nix
|
||||||
|
hpack.gup:
|
||||||
|
*.cabal
|
||||||
8
gup/cabal2nix.gup
Executable file
8
gup/cabal2nix.gup
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#! /usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i zsh -p zsh haskellPackages.cabal2nix
|
||||||
|
|
||||||
|
gup -u ${2:r}.cabal
|
||||||
|
|
||||||
|
cd ${2:h}
|
||||||
|
|
||||||
|
cabal2nix . > $1
|
||||||
6
gup/hpack.gup
Executable file
6
gup/hpack.gup
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#! /usr/bin/env nix-shell
|
||||||
|
#! nix-shell -i sh -p haskellPackages.hpack
|
||||||
|
|
||||||
|
gup -u package.yaml
|
||||||
|
|
||||||
|
hpack - >$1
|
||||||
50
shell.nix
Normal file
50
shell.nix
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{ nixpkgs ? import <nixpkgs> {}, compiler ? null }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) pkgs;
|
||||||
|
|
||||||
|
haskellPackages = if isNull compiler
|
||||||
|
then pkgs.haskellPackages
|
||||||
|
else pkgs.haskell.packages.${compiler};
|
||||||
|
|
||||||
|
drv = haskellPackages.callPackage ./uniworx.nix {};
|
||||||
|
|
||||||
|
postgresSchema = pkgs.writeText "schema.sql" ''
|
||||||
|
CREATE USER uniworx;
|
||||||
|
CREATE DATABASE uniworx_test;
|
||||||
|
GRANT ALL ON DATABASE uniworx_test TO uniworx;
|
||||||
|
'';
|
||||||
|
|
||||||
|
postgresHba = pkgs.writeText "hba_file" ''
|
||||||
|
local all all trust
|
||||||
|
'';
|
||||||
|
|
||||||
|
override = oldAttrs: {
|
||||||
|
nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ postgresql ]) ++ (with haskellPackages; [ stack stack-run yesod-bin ]);
|
||||||
|
shellHook = ''
|
||||||
|
${oldAttrs.shellHook}
|
||||||
|
export PROMPT_INFO="${oldAttrs.name}"
|
||||||
|
|
||||||
|
pgDir=$(mktemp -d)
|
||||||
|
pgSockDir=$(mktemp -d)
|
||||||
|
pgLogFile=$(mktemp)
|
||||||
|
pg_ctl init -D ''${pgDir}
|
||||||
|
pg_ctl start -D ''${pgDir} -l ''${pgLogFile} -w -o "-k ''${pgSockDir} -c listen_addresses=''' -c hba_file='${postgresHba}' -c unix_socket_permissions=0700"
|
||||||
|
export PGHOST=''${pgSockDir} PGLOG=''${pgLogFile}
|
||||||
|
psql -f ${postgresSchema} postgres
|
||||||
|
printf "Postgres logfile is %s\nPostgres socket directory is %s\n" ''${pgLogFile} ''${pgSockDir}
|
||||||
|
cat > .dbsettings.yml <<EOF
|
||||||
|
database:
|
||||||
|
host: ''${pgSockDir}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
zsh
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
pg_ctl stop -D ''${pgDir}
|
||||||
|
rm -rvf .dbsettings.yml ''${pgDir} ''${pgSockDir} ''${pgLogFile}
|
||||||
|
exit ''${ret}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in
|
||||||
|
pkgs.stdenv.lib.overrideDerivation drv.env override
|
||||||
11
stack.nix
Normal file
11
stack.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{ ghc, nixpkgs ? (import <nixpkgs> {}) }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) haskell pkgs;
|
||||||
|
in haskell.lib.buildStackProject {
|
||||||
|
inherit ghc;
|
||||||
|
name = "stackenv";
|
||||||
|
buildInputs = with pkgs;
|
||||||
|
[ postgresql zlib
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -64,3 +64,7 @@ extra-package-dbs: []
|
|||||||
#
|
#
|
||||||
# Allow a newer minor version of GHC than the snapshot specifies
|
# Allow a newer minor version of GHC than the snapshot specifies
|
||||||
# compiler-check: newer-minor
|
# compiler-check: newer-minor
|
||||||
|
|
||||||
|
nix:
|
||||||
|
packages: []
|
||||||
|
shell-file: ./stack.nix
|
||||||
|
|||||||
Reference in New Issue
Block a user