From: Julien Moutinho Date: Mon, 26 Dec 2022 01:22:26 +0000 (+0100) Subject: Add flake.nix X-Git-Url: https://git.sourcephile.fr/tmp/julm/arpeggigon.git/commitdiff_plain Add flake.nix --- diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/arpeggigon.cabal b/arpeggigon.cabal index 04e6178..8f4e76b 100644 --- a/arpeggigon.cabal +++ b/arpeggigon.cabal @@ -1,57 +1,69 @@ --- Initial arpeggigon.cabal generated by cabal init. For further --- documentation, see http://haskell.org/cabal/users-guide/ +name: arpeggigon +version: 0.1.0.0 -name: arpeggigon -version: 0.1.0.0 -- synopsis: -- description: -homepage: https://gitlab.com/chupin/reactogon -license: BSD3 -license-file: LICENSE -author: Guerric Chupin -maintainer: guerric.chupin@gmail.com +homepage: https://gitlab.com/chupin/reactogon +license: BSD3 +license-file: LICENSE +author: Guerric Chupin +maintainer: guerric.chupin@gmail.com + -- copyright: -- category: -build-type: Simple -extra-source-files: ChangeLog.md, README.md -cabal-version: >=1.10 -data-files: img/*.png, img/*.svg +build-type: Simple +extra-source-files: + ChangeLog.md + README.md + +cabal-version: 2.0 +data-files: + img/*.png + img/*.svg executable arpeggigon - main-is: RMCA/Main.hs - other-modules: Paths_arpeggigon - other-extensions: MultiParamTypeClasses - , ScopedTypeVariables - , Arrows - , FlexibleInstances - , TypeSynonymInstances - , FlexibleContexts - , GeneralizedNewtypeDeriving - build-depends: base >=4.7 && <4.10 - , bifunctors >= 5.4.1 && < 6 - , array >=0.5 && <0.6 - , keera-hails-reactivevalues >=0.2 && <0.3 - , Yampa >=0.10 && <0.11 - , gtk-helpers >=0.0 && <0.1 - , gtk >=0.14 && <0.15 - , keera-hails-reactive-gtk >=0.3 && <0.4 - , keera-hails-reactive-yampa >=0.0 && <0.1 - , containers >=0.5 && <0.6 - , jack >=0.7.1 && <0.8 - , midi >=0.2 && <0.3 - , explicit-exception >=0.1 && <0.2 - , transformers >=0.4 && <0.6 - , event-list >=0.1 && <0.2 - , keera-callbacks >=0.1 && <0.2 - , glib >=0.13 && <0.14 - hs-source-dirs: src - build-tools: hsc2hs - default-language: Haskell2010 - ghc-options: -O2 - -threaded - -Wall - -fno-warn-name-shadowing - -fno-warn-unused-do-bind + main-is: RMCA/Main.hs + other-modules: Paths_arpeggigon + autogen-modules: Paths_arpeggigon + other-extensions: + Arrows + FlexibleContexts + FlexibleInstances + GeneralizedNewtypeDeriving + MultiParamTypeClasses + ScopedTypeVariables + TypeSynonymInstances + + build-depends: + array >=0.5 && <0.6 + , base >=4.7 + , bifunctors >=5.4.1 && <6 + , containers >=0.5 + , event-list >=0.1 && <0.2 + , explicit-exception >=0.1 && <0.2 + , glib >=0.13 && <0.14 + , gtk >=0.14 + , gtk-helpers >=0.0 + , jack >=0.7.1 && <0.8 + , keera-callbacks >=0.1 && <0.2 + , keera-hails-reactive-gtk >=0.3 + , keera-hails-reactive-yampa >=0.0 + , keera-hails-reactivevalues >=0.2 + , midi >=0.2 && <0.3 + , transformers >=0.4 && <0.6 + , Yampa >=0.10 + + hs-source-dirs: src + + -- build-tools: hsc2hs + default-language: Haskell2010 + + -- Initial arpeggigon.cabal generated by cabal init. For further + -- documentation, see http://haskell.org/cabal/users-guide/ + + ghc-options: + -O2 -threaded -Wall -fno-warn-name-shadowing + -fno-warn-unused-do-bind -- executable arpeggigon.prof -- main-is: RMCA/Main.hs diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3a475e6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,135 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1668681692, + "narHash": "sha256-Ht91NGdewz8IQLtWZ9LCeNXMSXHUss+9COoqu6JLmXU=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "009399224d5e398d03b22badca40a37ac85412a1", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gtk-helpers": { + "flake": false, + "locked": { + "lastModified": 1598352854, + "narHash": "sha256-pSVquB2vEF7TthbQNcTgpcD14Gz3S/2fqBZ0YUZMFLo=", + "owner": "keera-studios", + "repo": "gtk-helpers", + "rev": "95366dc610dc8f0ffc80d57351a59f89be483df6", + "type": "github" + }, + "original": { + "owner": "keera-studios", + "repo": "gtk-helpers", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1667050928, + "narHash": "sha256-xOn0ZgjImIyeecEsrjxuvlW7IW5genTwvvnDQRFncB8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fdebb81f45a1ba2c4afca5fd9f526e1653ad0949", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1671271954, + "narHash": "sha256-cSvu+bnvN08sOlTBWbBrKaBHQZq8mvk8bgpt0ZJ2Snc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d513b448cc2a6da2c8803e3c197c9fc7e67b19e3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1671452357, + "narHash": "sha256-HqzXiQEegpRQ4VEl9pEPgHSIxhJrNJ27HfN1wOc7w2E=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "200790e9c77064c53eaf95805b013d96615ecc27", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "gtk-helpers": "gtk-helpers", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..44f86a4 --- /dev/null +++ b/flake.nix @@ -0,0 +1,84 @@ +{ + inputs = { + nixpkgs.url = "flake:nixpkgs"; + pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix"; + pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs"; + gtk-helpers.url = "github:keera-studios/gtk-helpers"; + gtk-helpers.flake = false; + }; + outputs = inputs: + let + pkg = "arpeggigon"; + inherit (inputs.nixpkgs) lib; + forAllSystems = f: lib.genAttrs lib.systems.flakeExposed (system: f rec { + inherit system; + pkgs = inputs.nixpkgs.legacyPackages.${system}; + # pkgs.haskellPackages currently defaults to GHC 9.0.1 + # Use something like pkgs.haskell.packages.ghc810 for a specific GHC version. + haskellPackages = pkgs.haskellPackages.extend (with pkgs.haskell.lib; hfinal: hsuper: { + ${pkg} = buildFromSdist (hfinal.callCabal2nix pkg ./. { }); + gtk-helpers = hfinal.callCabal2nix "gtk-helpers" + ( + pkgs.applyPatches + { + name = "gtk-helpers"; + src = inputs.gtk-helpers; + patches = map pkgs.fetchpatch [ + { + meta.description = "Fix build with GHC 9"; + url = "https://github.com/keera-studios/gtk-helpers/pull/13.diff"; + sha256 = "sha256-4wgLvvloBwC4zCKmfDQKCh3CrtRJ4zgLMaoEPJvF6fQ="; + } + ]; + } + "/gtk2" + ) + { }; + keera-hails-reactivevalues = dontCheck (doJailbreak (unmarkBroken hsuper.keera-hails-reactivevalues)); + }); + }); + in + rec { + # nix -L build + defaultPackage = forAllSystems ({ haskellPackages, ... }: haskellPackages.${pkg}); + packages = forAllSystems ({ haskellPackages, ... }: { }); + # nix -L develop or direnv allow + devShell = forAllSystems ({ pkgs, haskellPackages, system, ... }: + haskellPackages.shellFor { + packages = ps: [ + ps.${pkg} + ]; + nativeBuildInputs = [ + haskellPackages.cabal-install + #haskellPackages.ghcid + #haskellPackages.haskell-language-server + #haskellPackages.hlint + #haskellPackages.hsc2hs + #pkgs.git-chglog + #pkgs.reuse + #pkgs.gobject-introspection + #(pkgs.python3.withPackages (p: with p; [ + # pygobject3 + #])) + ]; + withHoogle = false; + inherit (checks.${system}.pre-commit-check) shellHook; + }); + # nix flake check + checks = forAllSystems (args: with args; { + pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { + src = ./.; + #settings.ormolu.cabalDefaultExtensions = true; + settings.ormolu.defaultExtensions = [ + "ImportQualifiedPost" + "TypeApplications" + ]; + hooks = { + hlint.enable = true; + nixpkgs-fmt.enable = true; + fourmolu.enable = true; + cabal-fmt.enable = true; + }; + }; + }); + }; +}