Make nix develop work

This commit is contained in:
Paul Brinkmeier 2023-04-02 17:03:35 +02:00
parent 12b53e72b5
commit 1a2d9edc99
5 changed files with 53 additions and 73 deletions

View File

@ -3,7 +3,7 @@
## Building the executable ## Building the executable
``` ```
$ nix run $ nix build
``` ```
## Building the Docker image ## Building the Docker image
@ -18,6 +18,12 @@ $ docker load < $(nix-build nix/docker-image.nix)
Includes Stack, `haskell-language-server`, `gen-hie` etc. Includes Stack, `haskell-language-server`, `gen-hie` etc.
``` ```
# TODO nix develop
$ nix-shell ```
## Running Stack and GHC
```
nix run .#stack
nix run .#ghc
``` ```

View File

@ -12,58 +12,64 @@
pkgs = nixpkgs.legacyPackages.x86_64-linux.extend overlay; pkgs = nixpkgs.legacyPackages.x86_64-linux.extend overlay;
haskellPackages = pkgs.haskell.packages."${settings.ghc}"; haskellPackages = pkgs.haskell.packages."${settings.ghc}";
ghc = haskellPackages.ghcWithPackages haskellDeps;
stack = pkgs.stdenv.mkDerivation { stack = pkgs.stdenv.mkDerivation {
pname = "stack"; name = "stack";
version = "0";
dontUnpack = true; dontUnpack = true;
dontConfigure = true; dontConfigure = true;
dontBuild = true; dontBuild = true;
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];
installPhase = '' installPhase = ''
makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \
--add-flags '--no-nix --no-install-ghc' --prefix PATH : ${ghc}/bin \
--add-flags '--no-nix --system-ghc --no-install-ghc'
''; '';
}; };
utoy' =
{ mkDerivation }:
mkDerivation {
version = "0.5";
pname = "utoy";
license = pkgs.lib.licenses.mit;
src =
let
buildFiles = [
./LICENSE
./utoy.cabal
./Setup.hs
./app
./src
./static
./test
];
in
pkgs.lib.sources.cleanSourceWith {
src = ./.;
filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) buildFiles;
};
libraryHaskellDepends = haskellDeps haskellPackages;
};
utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy' {});
in { in {
packages.x86_64-linux.stack = stack; packages.x86_64-linux = {
packages.x86_64-linux.utoy = inherit ghc;
let inherit stack;
utoy = inherit utoy;
{ mkDerivation }:
mkDerivation {
version = "0.5";
pname = "utoy";
license = pkgs.lib.licenses.mit;
src =
let
buildFiles = [
./LICENSE
./utoy.cabal
./Setup.hs
./app
./src
./static
./test
];
in
pkgs.lib.sources.cleanSourceWith {
src = ./.;
filter = path: _type: pkgs.lib.any (prefix: pkgs.lib.hasPrefix (toString prefix) path) buildFiles;
};
libraryHaskellDepends = haskellDeps haskellPackages; default = utoy;
}; };
in
pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy {});
packages.x86_64-linux.default = self.packages.x86_64-linux.utoy; devShells.x86_64-linux.default = pkgs.mkShell {
packages = [
devShells.default = pkgs.mkShell {
buildInputs = [
stack stack
ghc
haskellPackages.haskell-language-server
haskellPackages.implicit-hie
]; ];
shellHook = '' shellHook = ''
PS1+=" (utoy)"; PS1+="(utoy) ";
''; '';
}; };
}; };

View File

@ -1,17 +0,0 @@
{ pkgs ? import ./nix/pkgs.nix {} }:
let
haskellDeps = import ./nix/haskell-deps.nix;
settings = import ./nix/settings.nix;
haskellPackages = pkgs.haskell.packages."${settings.ghc}";
tools = with pkgs; [
# haskell tools
stack
(haskellPackages.ghcWithPackages haskellDeps)
haskellPackages.haskell-language-server
haskellPackages.implicit-hie
];
in
pkgs.mkShellNoCC {
nativeBuildInputs = tools;
}

View File

@ -1,10 +0,0 @@
{}:
let
pkgs = import ./nix/pkgs.nix {};
haskellDeps = import ./nix/haskell-deps.nix;
settings = import ./nix/settings.nix;
in
pkgs.haskell.lib.buildStackProject {
name = "utoy";
ghc = pkgs.haskell.packages."${settings.ghc}".ghcWithPackages haskellDeps;
}

View File

@ -1,9 +1,4 @@
# You can get a working environment using nix develop.
resolver: ghc-9.4.4 resolver: ghc-9.4.4
# GHC is managed through Nix
install-ghc: false
packages: packages:
- . - .
nix:
enable: true
shell-file: stack-shell.nix
path: ["nixpkgs=./nix/pkgs.nix"]