]> Git — Sourcephile - tmp/julm/alpmestan-sounds.git/commitdiff
repro(env): add a Nix flake main
authorJulien Moutinho <julm@sourcephile.fr>
Sun, 13 Oct 2024 12:13:35 +0000 (14:13 +0200)
committerJulien Moutinho <julm@sourcephile.fr>
Sun, 13 Oct 2024 12:18:00 +0000 (14:18 +0200)
.envrc
.gitignore [new file with mode: 0644]
flake.lock [new file with mode: 0644]
flake.nix [new file with mode: 0644]

diff --git a/.envrc b/.envrc
index df99a55f05c060c33d40918cfe131065378a0b8d..3550a30f2de389e537ee40ca5e64a77dc185c79b 100644 (file)
--- a/.envrc
+++ b/.envrc
@@ -1 +1 @@
-use nix shell.nix
+use flake
diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..c2ce3f8
--- /dev/null
@@ -0,0 +1,24 @@
+*.actual.*
+*.eventlog
+*.eventlog.html
+*.eventlog.json
+*.hi
+*.hp
+*.o
+*.orig
+*.prof
+*.root
+.direnv/
+.ghc.environment.*
+.gitsigners
+.pre-commit-config.yaml
+.stack-work/
+cabal.project.local
+core
+dist-newstyle/
+dist/
+dump-core/
+hlint.html
+old/
+result*
+sydtest-profile.html
diff --git a/flake.lock b/flake.lock
new file mode 100644 (file)
index 0000000..ff6f195
--- /dev/null
@@ -0,0 +1,153 @@
+{
+  "nodes": {
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696426674,
+        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1710146030,
+        "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "git-hooks": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils",
+        "gitignore": "gitignore",
+        "nixpkgs": [
+          "nixpkgs"
+        ],
+        "nixpkgs-stable": "nixpkgs-stable"
+      },
+      "locked": {
+        "lastModified": 1715609711,
+        "narHash": "sha256-/5u29K0c+4jyQ8x7dUIEUWlz2BoTSZWUP2quPwFCE7M=",
+        "owner": "cachix",
+        "repo": "git-hooks.nix",
+        "rev": "c182c876690380f8d3b9557c4609472ebfa1b141",
+        "type": "github"
+      },
+      "original": {
+        "owner": "cachix",
+        "repo": "git-hooks.nix",
+        "type": "github"
+      }
+    },
+    "gitignore": {
+      "inputs": {
+        "nixpkgs": [
+          "git-hooks",
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1709087332,
+        "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
+        "owner": "hercules-ci",
+        "repo": "gitignore.nix",
+        "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
+        "type": "github"
+      },
+      "original": {
+        "owner": "hercules-ci",
+        "repo": "gitignore.nix",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1727264057,
+        "narHash": "sha256-KQPI8CTTnB9CrJ7LrmLC4VWbKZfljEPBXOFGZFRpxao=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "759537f06e6999e141588ff1c9be7f3a5c060106",
+        "type": "github"
+      },
+      "original": {
+        "id": "nixpkgs",
+        "type": "indirect"
+      }
+    },
+    "nixpkgs-stable": {
+      "locked": {
+        "lastModified": 1710695816,
+        "narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "614b4613980a522ba49f0d194531beddbb7220d3",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-23.11",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "proteaaudio": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1700523856,
+        "narHash": "sha256-3T+HDQCZ+WsUxyEXdfaraPHqj82WujOtZBlhjKx5z2o=",
+        "owner": "csabahruska",
+        "repo": "proteaaudio",
+        "rev": "ec097b0cce0b2fb2835971e39618a06937d9485b",
+        "type": "github"
+      },
+      "original": {
+        "owner": "csabahruska",
+        "repo": "proteaaudio",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "git-hooks": "git-hooks",
+        "nixpkgs": "nixpkgs",
+        "proteaaudio": "proteaaudio"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644 (file)
index 0000000..02c0800
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,98 @@
+{
+  description = "sounds";
+  inputs = {
+    nixpkgs.url = "flake:nixpkgs";
+    git-hooks.url = "github:cachix/git-hooks.nix";
+    git-hooks.inputs.nixpkgs.follows = "nixpkgs";
+    proteaaudio = { url = "github:csabahruska/proteaaudio"; flake = false; };
+  };
+  outputs = inputs:
+    let
+      pkg = "sounds";
+      lib = inputs.nixpkgs.lib;
+      fileInputs = with lib.fileset; toSource {
+        root = ./.;
+        fileset = unions [
+          ./sounds.cabal
+          ./CHANGELOG.md
+          #./Readme.md
+          ./LICENSE
+          (fileFilter (file: lib.any file.hasExt [ "hs" ]) ./exe)
+        ];
+      };
+      perSystem = f: lib.genAttrs lib.systems.flakeExposed (system: f rec {
+        inherit system;
+        pkgs = inputs.nixpkgs.legacyPackages.${system};
+        haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib.compose; finalHaskellPkgs: previousHaskellPkgs: {
+          ${pkg} = buildFromSdist (finalHaskellPkgs.callCabal2nix pkg fileInputs { });
+          lambdasound = (doJailbreak (unmarkBroken previousHaskellPkgs.lambdasound)).overrideAttrs (previousAttrs: {
+            # ExplanationNote: one of lambdasound's test tries to write in `$HOME`
+            # which defaults to the non-existent directory `/homeless-shelter`.
+            HOME = "/tmp";
+          });
+          plots = doJailbreak (unmarkBroken previousHaskellPkgs.plots);
+          proteaaudio = lib.pipe
+            (finalHaskellPkgs.callCabal2nix "proteaaudio" "${inputs.proteaaudio}/proteaaudio" {
+              libpulse = pkgs.libpulseaudio;
+              libpulse-simple = pkgs.libpulseaudio.dev;
+            }) [
+            (overrideCabal (previousDrv: {
+              # ExplanationNote: because
+              # `proteaaudio/proteaaudio/Sound/ProteaAudio.chs`
+              # symlinks to `../../chs/Binding.chs`
+              # the sibling directory ${inputs.proteaaudio}/cbits
+              # must be available too.
+              src = inputs.proteaaudio;
+              postUnpack = "sourceRoot=$sourceRoot/proteaaudio";
+            }))
+          ];
+        });
+      });
+    in
+    rec {
+      # nix -L build
+      packages = perSystem ({ haskellPackages, ... }: {
+        default = haskellPackages.${pkg};
+      });
+      # nix -L develop  or  direnv allow
+      devShells = perSystem ({ pkgs, haskellPackages, system, ... }: {
+        default =
+          haskellPackages.shellFor {
+            packages = ps: [
+              ps.${pkg}
+            ];
+            nativeBuildInputs = [
+              haskellPackages.cabal-install
+              haskellPackages.cabal2nix
+              haskellPackages.haskell-language-server
+              haskellPackages.hlint
+              pkgs.ghciwatch
+              pkgs.git-cliff
+              pkgs.reuse
+            ];
+            #withHoogle = true;
+            inherit (checks.${system}.git-hooks-check) shellHook;
+          };
+      });
+      # nix flake check
+      checks = perSystem (args: with args; {
+        git-hooks-check = inputs.git-hooks.lib.${system}.run {
+          src = ./.;
+          hooks = {
+            cabal-fmt.enable = true;
+            fourmolu.enable = true;
+            hlint.enable = true;
+            nixpkgs-fmt.enable = true;
+            ormolu.settings.cabalDefaultExtensions = true;
+            /*
+            reuse = {
+              enable = true;
+              entry = "${pkgs.reuse}/bin/reuse lint";
+              pass_filenames = false;
+            };
+            */
+          };
+        };
+      });
+    };
+}