diff --git a/flake.lock b/flake.lock index 28ec18d..16e9863 100644 --- a/flake.lock +++ b/flake.lock @@ -1,146 +1,77 @@ { "nodes": { - "flake-utils": { + "garnix-lib": { "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" + "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "lastModified": 1738237019, + "narHash": "sha256-nVJj6z2HeOWi35W7RoG71ErD9IKuymLVa0BR95vV+Hs=", + "owner": "garnix-io", + "repo": "garnix-lib", + "rev": "0573417fc462b0eeed5d762c8fe08093afb35a3d", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "garnix-io", + "repo": "garnix-lib", "type": "github" } }, - "gomod2nix-repo": { + "haskell-module": { "inputs": { - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1694616124, - "narHash": "sha256-c49BVhQKw3XDRgt+y+uPAbArtgUlMXCET6VxEBmzHXE=", - "owner": "nix-community", - "repo": "gomod2nix", - "rev": "f95720e89af6165c8c0aa77f180461fe786f3c21", + "lastModified": 1740688310, + "narHash": "sha256-f+r52Oci2q/tpgMKOfPRJEuectZDcPJW8TtNbEpZfP0=", + "owner": "garnix-io", + "repo": "haskell-module", + "rev": "2734fa0b86a0aceca28821882c49d065af443d88", "type": "github" }, "original": { - "owner": "nix-community", - "repo": "gomod2nix", - "rev": "f95720e89af6165c8c0aa77f180461fe786f3c21", + "owner": "garnix-io", + "repo": "haskell-module", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1658285632, - "narHash": "sha256-zRS5S/hoeDGUbO+L95wXG9vJNwsSYcl93XiD0HQBXLk=", + "lastModified": 1737569578, + "narHash": "sha256-6qY0pk2QmUtBT9Mywdvif0i/CLVgpCjMUn6g9vB+f3M=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5342fc6fb59d0595d26883c3cadff16ce58e44f3", + "rev": "47addd76727f42d351590c905d9d1905ca895b82", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", + "ref": "nixos-24.11", "repo": "nixpkgs", "type": "github" } }, "nixpkgs_2": { "locked": { - "lastModified": 1697912416, - "narHash": "sha256-2MLnJ9vLbiSyfA+mYHPdN76qAOfacJw/dX/sSiYdo2o=", + "lastModified": 1733550349, + "narHash": "sha256-NcGumB4Lr6KSDq+nIqXtNA8QwAQKDSZT7N9OTGWbTrs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "21443a102b1a2f037d02e1d22e3e0ffdda2dbff9", + "rev": "e2605d0744c2417b09f8bf850dfca42fcf537d34", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-24.11", "repo": "nixpkgs", - "rev": "21443a102b1a2f037d02e1d22e3e0ffdda2dbff9", - "type": "github" - } - }, - "npmlock2nix-repo": { - "flake": false, - "locked": { - "lastModified": 1673447413, - "narHash": "sha256-sJM82Sj8yfQYs9axEmGZ9Evzdv/kDcI9sddqJ45frrU=", - "owner": "nix-community", - "repo": "npmlock2nix", - "rev": "9197bbf397d76059a76310523d45df10d2e4ca81", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "npmlock2nix", - "rev": "9197bbf397d76059a76310523d45df10d2e4ca81", "type": "github" } }, "root": { "inputs": { - "flake-utils": "flake-utils", - "gomod2nix-repo": "gomod2nix-repo", - "nixpkgs": "nixpkgs_2", - "npmlock2nix-repo": "npmlock2nix-repo" - } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_2": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" + "garnix-lib": "garnix-lib", + "haskell-module": "haskell-module" } } }, diff --git a/flake.nix b/flake.nix index d92a539..10cf3ff 100644 --- a/flake.nix +++ b/flake.nix @@ -1,253 +1,16 @@ { - inputs.nixpkgs.url = "github:NixOS/nixpkgs/21443a102b1a2f037d02e1d22e3e0ffdda2dbff9"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.gomod2nix-repo.url = "github:nix-community/gomod2nix?rev=f95720e89af6165c8c0aa77f180461fe786f3c21"; - inputs.npmlock2nix-repo = { - url = "github:nix-community/npmlock2nix?rev=9197bbf397d76059a76310523d45df10d2e4ca81"; - flake = false; + inputs = { + garnix-lib.url = "github:garnix-io/garnix-lib"; + haskell-module.url = "github:garnix-io/haskell-module"; }; - outputs = { self, nixpkgs, flake-utils, npmlock2nix-repo, gomod2nix-repo }: - let - systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - in - { - packages = forAllSystems (system: - let - pkgs = import "${nixpkgs}" { - config.allowUnfree = true; - inherit system; - }; - in - { - "main_pkg" = - (pkgs.haskell.packages.ghc94.callCabal2nix - "garn-pkg" - - ( - let - lib = pkgs.lib; - lastSafe = list: - if lib.lists.length list == 0 - then null - else lib.lists.last list; - in - builtins.path - { - path = ./.; - name = "source"; - filter = path: type: - let - fileName = lastSafe (lib.strings.splitString "/" path); - in - fileName != "flake.nix" && - fileName != "garn.ts"; - } - ) - - { }) - // { - meta.mainProgram = "is-cached"; - } - ; - } - ); - checks = forAllSystems (system: - let - pkgs = import "${nixpkgs}" { - config.allowUnfree = true; - inherit system; - }; - in - { } - ); - devShells = forAllSystems (system: - let - pkgs = import "${nixpkgs}" { - config.allowUnfree = true; - inherit system; - }; - in - { - "main" = - ( - ( - let - expr = - (pkgs.haskell.packages.ghc94.callCabal2nix - "garn-pkg" - - ( - let - lib = pkgs.lib; - lastSafe = list: - if lib.lists.length list == 0 - then null - else lib.lists.last list; - in - builtins.path - { - path = ./.; - name = "source"; - filter = path: type: - let - fileName = lastSafe (lib.strings.splitString "/" path); - in - fileName != "flake.nix" && - fileName != "garn.ts"; - } - ) - - { }) - // { - meta.mainProgram = "is-cached"; - } - ; - in - (if expr ? env - then expr.env - else pkgs.mkShell { inputsFrom = [ expr ]; } - ) - ).overrideAttrs (finalAttrs: previousAttrs: { - nativeBuildInputs = - previousAttrs.nativeBuildInputs - ++ - [ pkgs.haskell.packages.ghc94.cabal-install ]; - }) - ).overrideAttrs (finalAttrs: previousAttrs: { - nativeBuildInputs = - previousAttrs.nativeBuildInputs - ++ - [ - (pkgs.haskell-language-server.override { - dynamic = true; - supportedGhcVersions = [ "945" ]; - }) - ]; - }) - ; - } - ); - apps = forAllSystems (system: - let - pkgs = import "${nixpkgs}" { inherit system; }; - in - { - "dev" = { - "type" = "app"; - "program" = "${ - let - dev = - ( - ( - let expr = - (pkgs.haskell.packages.ghc94.callCabal2nix - "garn-pkg" - - (let - lib = pkgs.lib; - lastSafe = list : - if lib.lists.length list == 0 - then null - else lib.lists.last list; - in - builtins.path - { - path = ./.; - name = "source"; - filter = path: type: - let - fileName = lastSafe (lib.strings.splitString "/" path); - in - fileName != "flake.nix" && - fileName != "garn.ts"; - }) - - { }) - // { - meta.mainProgram = "is-cached"; - } - ; - in - (if expr ? env - then expr.env - else pkgs.mkShell { inputsFrom = [ expr ]; } - ) - ).overrideAttrs (finalAttrs: previousAttrs: { - nativeBuildInputs = - previousAttrs.nativeBuildInputs - ++ - [pkgs.haskell.packages.ghc94.cabal-install]; - }) - ).overrideAttrs (finalAttrs: previousAttrs: { - nativeBuildInputs = - previousAttrs.nativeBuildInputs - ++ - [(pkgs.haskell-language-server.override { - dynamic = true; - supportedGhcVersions = [ "945" ]; - })]; - }) - ; - shell = "runhaskell Main.hs"; - buildPath = pkgs.runCommand "build-inputs-path" { - inherit (dev) buildInputs nativeBuildInputs; - } "echo $PATH > $out"; - in - pkgs.writeScript "shell-env" '' - #!${pkgs.bash}/bin/bash - export PATH=$(cat ${buildPath}):$PATH - ${dev.shellHook} - ${shell} "$@" - '' - }"; - }; - "main" = { - "type" = "app"; - "program" = "${ - let - dev = pkgs.mkShell {}; - shell = "${ - (pkgs.haskell.packages.ghc94.callCabal2nix - "garn-pkg" - - (let - lib = pkgs.lib; - lastSafe = list : - if lib.lists.length list == 0 - then null - else lib.lists.last list; - in - builtins.path - { - path = ./.; - name = "source"; - filter = path: type: - let - fileName = lastSafe (lib.strings.splitString "/" path); - in - fileName != "flake.nix" && - fileName != "garn.ts"; - }) - - { }) - // { - meta.mainProgram = "is-cached"; - } - }/bin/is-cached"; - buildPath = pkgs.runCommand "build-inputs-path" { - inherit (dev) buildInputs nativeBuildInputs; - } "echo $PATH > $out"; - in - pkgs.writeScript "shell-env" '' - #!${pkgs.bash}/bin/bash - export PATH=$(cat ${buildPath}):$PATH - ${dev.shellHook} - ${shell} "$@" - '' - }"; - }; - } - ); + outputs = inputs: inputs.garnix-lib.lib.mkModules { + modules = [ + inputs.haskell-module.garnixModules.default + ]; + config = { pkgs, ... }: { + haskell.default = { + src = ./.; + }; }; + }; } diff --git a/garn.ts b/garn.ts deleted file mode 100644 index c94c15b..0000000 --- a/garn.ts +++ /dev/null @@ -1,20 +0,0 @@ -import * as garn from "https://garn.io/ts/v0.0.10/mod.ts"; -import { nixRaw } from "https://garn.io/ts/v0.0.10/nix.ts"; - -export const main = garn.haskell - .mkHaskellProject({ - description: "is-cached", - executable: "is-cached", - compiler: "ghc94", - src: ".", - }) - .withDevTools([ - garn.mkPackage(nixRaw` - (pkgs.haskell-language-server.override { - dynamic = true; - supportedGhcVersions = [ "945" ]; - }) - `), - ]); - -export const dev: garn.Executable = main.shell`runhaskell Main.hs`;