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,23 +12,20 @@
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'
''; '';
}; };
in { utoy' =
packages.x86_64-linux.stack = stack;
packages.x86_64-linux.utoy =
let
utoy =
{ mkDerivation }: { mkDerivation }:
mkDerivation { mkDerivation {
version = "0.5"; version = "0.5";
@ -53,17 +50,26 @@
libraryHaskellDepends = haskellDeps haskellPackages; libraryHaskellDepends = haskellDeps haskellPackages;
}; };
in utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy' {});
pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy {}); in {
packages.x86_64-linux = {
inherit ghc;
inherit stack;
inherit utoy;
packages.x86_64-linux.default = self.packages.x86_64-linux.utoy; default = utoy;
};
devShells.default = pkgs.mkShell { devShells.x86_64-linux.default = pkgs.mkShell {
buildInputs = [ packages = [
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"]