From 349669b48ee18edfb9b6e6adabc92e71b4a496db Mon Sep 17 00:00:00 2001 From: Jonathan Lorimer Date: Wed, 10 Jul 2024 14:44:02 -0400 Subject: [PATCH] feat: get ci unstuck on broken flake --- flake.lock | 27 ++++++-- flake.nix | 182 ++++++++++++++++++++++++++++++----------------------- 2 files changed, 124 insertions(+), 85 deletions(-) diff --git a/flake.lock b/flake.lock index 325f57b..3e8d0a5 100644 --- a/flake.lock +++ b/flake.lock @@ -33,16 +33,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1701539137, - "narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=", + "lastModified": 1720553833, + "narHash": "sha256-IXMiHQMtdShDXcBW95ctA+m5Oq2kLxnBt7WlMxvDQXA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d", + "rev": "249fbde2a178a2ea2638b65b9ecebd531b338cf9", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-24.05", "repo": "nixpkgs", "type": "github" } @@ -51,7 +51,24 @@ "inputs": { "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "tmp-postgres-src": "tmp-postgres-src" + } + }, + "tmp-postgres-src": { + "flake": false, + "locked": { + "lastModified": 1691516008, + "narHash": "sha256-dE1OQN7I4Lxy6RBdLCvm75Z9D/Hu+9G4ejV2pEtvL1A=", + "owner": "jfischoff", + "repo": "tmp-postgres", + "rev": "7f2467a6d6d5f6db7eed59919a6773fe006cf22b", + "type": "github" + }, + "original": { + "owner": "jfischoff", + "repo": "tmp-postgres", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 44f8b13..c8a240c 100644 --- a/flake.nix +++ b/flake.nix @@ -3,101 +3,123 @@ inputs = { flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; flake-compat = { url = "github:edolstra/flake-compat"; flake = false; }; + tmp-postgres-src = { + url = "github:jfischoff/tmp-postgres"; + flake = false; + }; }; - outputs = { self, flake-utils, nixpkgs, flake-compat }: + outputs = { + self, + flake-utils, + nixpkgs, + flake-compat, + tmp-postgres-src, + }: flake-utils.lib.eachDefaultSystem - (system: - let - compiler = "ghc963"; - pkgs = nixpkgs.legacyPackages."${system}".extend self.overlay; - ghc = pkgs.haskell.packages."${compiler}"; - in - { - apps.repl = flake-utils.lib.mkApp { - drv = nixpkgs.legacyPackages."${system}".writeShellScriptBin "repl" '' - confnix=$(mktemp) - echo "builtins.getFlake (toString $(git rev-parse --show-toplevel))" >$confnix - trap "rm $confnix" EXIT - nix repl $confnix - ''; - }; + (system: let + compiler = "ghc963"; + pkgs = nixpkgs.legacyPackages."${system}".extend self.overlay; + ghc = pkgs.haskell.packages."${compiler}"; + in { + apps.repl = flake-utils.lib.mkApp { + drv = nixpkgs.legacyPackages."${system}".writeShellScriptBin "repl" '' + confnix=$(mktemp) + echo "builtins.getFlake (toString $(git rev-parse --show-toplevel))" >$confnix + trap "rm $confnix" EXIT + nix repl $confnix + ''; + }; - devShells.default = ghc.shellFor { - withHoogle = false; - packages = hpkgs: - with hpkgs; - with pkgs.haskell.lib; - [ hasql-interpolate - ]; - buildInputs = [ - pkgs.cabal-install - ]; - }; + devShells.default = ghc.shellFor { + withHoogle = false; + packages = hpkgs: + with hpkgs; + with pkgs.haskell.lib; [ + hasql-interpolate + ]; + buildInputs = [ + pkgs.cabal-install + ]; + }; - packages = { hasql-interpolate = ghc.hasql-interpolate; }; + packages = {hasql-interpolate = ghc.hasql-interpolate;}; - nixpkgs = pkgs; + nixpkgs = pkgs; - defaultPackage = self.packages."${system}".hasql-interpolate; + defaultPackage = self.packages."${system}".hasql-interpolate; - checks = pkgs.lib.attrsets.genAttrs [ "ghc928" "ghc947" "ghc963" ] - (ghc-ver: pkgs.haskell.packages."${ghc-ver}".hasql-interpolate); - }) // { + checks = + pkgs.lib.attrsets.genAttrs ["ghc928" "ghc947" "ghc963"] + (ghc-ver: pkgs.haskell.packages."${ghc-ver}".hasql-interpolate); + }) + // { overlay = final: prev: { haskell = with prev.haskell.lib; - prev.haskell // { - packages = - let - ghcs = prev.lib.filterAttrs - (k: v: prev.lib.strings.hasPrefix "ghc" k) - prev.haskell.packages; - patchedGhcs = builtins.mapAttrs patchGhc ghcs; - patchGhc = k: v: - prev.haskell.packages."${k}".extend (self: super: - with prev.haskell.lib; - with builtins; - with prev.lib.strings; - let - cleanSource = pth: - let - src' = prev.lib.cleanSourceWith { - filter = filt; - src = pth; - }; - filt = path: type: - let - bn = baseNameOf path; - isHiddenFile = hasPrefix "." bn; - isFlakeLock = bn == "flake.lock"; - isNix = hasSuffix ".nix" bn; - in - !isHiddenFile && !isFlakeLock && !isNix; - in - src'; + prev.haskell + // { + packages = let + ghcs = + prev.lib.filterAttrs + (k: v: prev.lib.strings.hasPrefix "ghc" k) + prev.haskell.packages; + patchedGhcs = builtins.mapAttrs patchGhc ghcs; + patchGhc = k: v: + prev.haskell.packages."${k}".extend (self: super: + with prev.haskell.lib; + with builtins; + with prev.lib.strings; let + cleanSource = pth: let + src' = prev.lib.cleanSourceWith { + filter = filt; + src = pth; + }; + filt = path: type: let + bn = baseNameOf path; + isHiddenFile = hasPrefix "." bn; + isFlakeLock = bn == "flake.lock"; + isNix = hasSuffix ".nix" bn; + in + !isHiddenFile && !isFlakeLock && !isNix; + in + src'; + in { + generic-monoid = doJailbreak super.generic-monoid; + tagged = doJailbreak super.tagged; + tmp-postgres = dontCheck (super.callCabal2nix "tmp-postgres" tmp-postgres-src {}); + hasql = dontCheck (super.callHackageDirect { + pkg = "hasql"; + ver = "1.8"; + sha256 = "sha256-+ZTJTIROjNqkOPkDtnhNQFq99Pi4IhOyIRcDqxqQbgY="; + } {}); + postgresql-binary = dontCheck (super.callHackageDirect { + pkg = "postgresql-binary"; + ver = "0.14"; + sha256 = "sha256-ldXhe3JpdOXQvB7LE+5D4SUpNuwRjfw7zceV9BTVcUA="; + } {}); + postgresql-libpq = dontCheck (super.callHackageDirect { + pkg = "postgresql-libpq"; + ver = "0.10.1.0"; + sha256 = "sha256-tXOMqCO8opMilI9rx0D+njqjIjbZsH168Bzb8Aq8Ff4="; + } {}); + hasql-interpolate = let + p = + self.callCabal2nix "hasql-interpolate" + (cleanSource ./.) + {}; in - { - generic-monoid = doJailbreak super.generic-monoid; - postgresql-libpq = doJailbreak super.postgresql-libpq; - tagged = doJailbreak super.tagged; - hasql-interpolate = - let - p = self.callCabal2nix "hasql-interpolate" - (cleanSource ./.) - { }; - in - overrideCabal p (drv: { - testToolDepends = [ prev.postgresql ]; - revision = null; - editedCabalFile = null; - }); - }); - in + overrideCabal p (drv: { + testToolDepends = [prev.postgresql]; + revision = null; + editedCabalFile = null; + }); + }); + in prev.haskell.packages // patchedGhcs; }; };