From a37643b5cdd52aae8f41aac7a1ebe931d1f43ccd Mon Sep 17 00:00:00 2001 From: Paul Brinkmeier Date: Sat, 22 Feb 2025 11:44:49 +0100 Subject: [PATCH] Simplify nix setup --- README.md | 4 +++ flake.nix | 83 ++++++++------------------------------------ nix/haskell-deps.nix | 13 ------- nix/settings.nix | 5 --- package.yaml | 70 ------------------------------------- stack.yaml | 5 --- 6 files changed, 19 insertions(+), 161 deletions(-) delete mode 100644 nix/haskell-deps.nix delete mode 100644 nix/settings.nix delete mode 100644 package.yaml delete mode 100644 stack.yaml diff --git a/README.md b/README.md index 608ce08..ca87bfb 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,7 @@ $ nix develop $ nix run .#stack $ nix run .#ghc ``` + +## TODO + +- [ ] Benchmark, profile and optimize search diff --git a/flake.nix b/flake.nix index d2abcde..7f685cd 100644 --- a/flake.nix +++ b/flake.nix @@ -5,85 +5,32 @@ outputs = { self, nixpkgs }: let - settings = import ./nix/settings.nix; - haskellDeps = import ./nix/haskell-deps.nix; - pkgs = nixpkgs.legacyPackages.x86_64-linux; - haskellPackages = pkgs.haskell.packages."${settings.ghc}"; - ghc = haskellPackages.ghcWithPackages haskellDeps; - - # Wrap stack to disable its slow Nix integration. - # Instead, make it use the GHC defined above. - stack = pkgs.stdenv.mkDerivation { - name = "stack"; - - # The build is simply a call to makeWrapper, so we don't have to - # do any of the typical build steps. - phases = [ "installPhase" ]; - - nativeBuildInputs = [ pkgs.makeWrapper ]; - # makeBinaryWrapper creates a stack executable for us that uses - # the GHC defined in this file. - installPhase = '' - makeWrapper ${pkgs.stack}/bin/stack $out/bin/stack \ - --prefix PATH : ${ghc}/bin \ - --add-flags '--no-nix --system-ghc --no-install-ghc' - ''; + utoy = pkgs.haskellPackages.developPackage { + root = ./.; }; - - utoy = pkgs.haskell.lib.justStaticExecutables (haskellPackages.callPackage - ({ mkDerivation }: - mkDerivation { - # Keep this in sync with package.yaml - version = "0.6.1"; - pname = "utoy"; - license = pkgs.lib.licenses.mit; - src = - # We only need these files for building: - let - whitelist = [ - ./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) whitelist; - }; - libraryHaskellDepends = haskellDeps haskellPackages; - }) {}); in { - packages.x86_64-linux = { - inherit ghc; - inherit stack; - - docker = + packages.x86_64-linux = rec { + docker = pkgs.dockerTools.buildImage { name = "git.pbrinkmeier.de/paul/utoy"; tag = utoy.version; - config.Cmd = [ "${utoy}/bin/utoy" ]; + config.Cmd = [ "${pkgs.haskell.lib.justStaticExecutables utoy}/bin/utoy" ]; }; default = utoy; }; - devShells.x86_64-linux.default = pkgs.mkShell { - packages = [ - stack - ghc - - haskellPackages.haskell-language-server - haskellPackages.implicit-hie - ]; - shellHook = '' - PS1+="(utoy) "; - ''; - }; + devShells.x86_64-linux.default = + (pkgs.haskellPackages.developPackage { + root = ./.; + modifier = drv: + pkgs.haskell.lib.addBuildTools drv [ + pkgs.cabal-install + pkgs.haskellPackages.implicit-hie + pkgs.haskell-language-server + ]; + }).env; }; } diff --git a/nix/haskell-deps.nix b/nix/haskell-deps.nix deleted file mode 100644 index 057a111..0000000 --- a/nix/haskell-deps.nix +++ /dev/null @@ -1,13 +0,0 @@ -haskellPackages: with haskellPackages; [ - attoparsec - blaze-html - bytestring - file-embed - http-media - servant-server - text - unicode-data - unicode-data-names - wai - warp -] diff --git a/nix/settings.nix b/nix/settings.nix deleted file mode 100644 index 70fc28b..0000000 --- a/nix/settings.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - # GHC version to use with Nix. - # Should match the one in stack.yaml. - ghc = "ghc944"; -} diff --git a/package.yaml b/package.yaml deleted file mode 100644 index 5a26fda..0000000 --- a/package.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# Adapted from new-template.hsfiles - -name: utoy -# Keep this in sync with the version in flake.nix. -version: 0.6.1 -git: "https://git.pbrinkmeier.de/paul/utoy" -license: MIT -author: "Paul Brinkmeier" -maintainer: "hallo@pbrinkmeier.de" -copyright: "2023 Paul Brinkmeier" - -extra-source-files: -- README.md -- static/utoy.css - -dependencies: -- base >= 4.7 && < 5 -- attoparsec -- text - -ghc-options: -- -Wall -- -Wcompat -- -Widentities -- -Wincomplete-record-updates -- -Wincomplete-uni-patterns -- -Wmissing-export-lists -- -Wmissing-home-modules -- -Wpartial-fields -- -Wredundant-constraints - -library: - source-dirs: src - -executables: - utoy: - main: Main.hs - source-dirs: app - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - utoy - - blaze-html - - bytestring - - file-embed - - http-media - - servant-server - - text - - unicode-data - - unicode-data-names - - wai - - warp - # Fix "Multiple files use the same module name", see - # https://stackoverflow.com/questions/67519851/multiple-files-use-the-same-module-name - when: - - condition: false - other-modules: Paths_utoy - -tests: - utoy-test: - main: Spec.hs - source-dirs: test - ghc-options: - - -threaded - - -rtsopts - - -with-rtsopts=-N - dependencies: - - utoy diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index 737c32b..0000000 --- a/stack.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# You can get a working environment using nix develop. -# Keep this in sync with nix/settings.nix -resolver: ghc-9.4.4 -packages: -- .