diff --git a/flake.nix b/flake.nix index 1a8526a..d045dce 100644 --- a/flake.nix +++ b/flake.nix @@ -3,45 +3,68 @@ inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - outputs = { self, nixpkgs }: { + outputs = { self, nixpkgs }: + let + overlay = import ./nix/overlay.nix; + settings = import ./nix/settings.nix; + haskellDeps = import ./nix/haskell-deps.nix; - packages.x86_64-linux.utoy = - let - overlay = import ./nix/overlay.nix; - pkgs = nixpkgs.legacyPackages.x86_64-linux.extend overlay; - settings = import ./nix/settings.nix; - haskellDeps = import ./nix/haskell-deps.nix; + pkgs = nixpkgs.legacyPackages.x86_64-linux.extend overlay; + haskellPackages = pkgs.haskell.packages."${settings.ghc}"; - haskellPackages = pkgs.haskell.packages."${settings.ghc}"; + stack = pkgs.stdenv.mkDerivation { + pname = "stack"; + version = "0"; + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + nativeBuildInputs = [ pkgs.makeWrapper ]; + installPhase = '' + makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ + --add-flags '--no-nix --no-install-ghc' + ''; + }; + in { + packages.x86_64-linux.stack = stack; + packages.x86_64-linux.utoy = + let + 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; + }; - 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; + }; + in + pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy {}); - libraryHaskellDepends = haskellDeps haskellPackages; - }; - in - pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage utoy {}); + packages.x86_64-linux.default = self.packages.x86_64-linux.utoy; - packages.x86_64-linux.default = self.packages.x86_64-linux.utoy; + devShells.default = pkgs.mkShell { + buildInputs = [ + stack + ]; + shellHook = '' + PS1+=" (utoy)"; + ''; + }; }; } diff --git a/shell.nix b/shell.nix index e95d7f9..04a9521 100644 --- a/shell.nix +++ b/shell.nix @@ -5,10 +5,6 @@ let haskellPackages = pkgs.haskell.packages."${settings.ghc}"; tools = with pkgs; [ - # nix tools - niv - nix-tree - # haskell tools stack (haskellPackages.ghcWithPackages haskellDeps)