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/.gitignore b/.gitignore index 38bb2b4..38e8629 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,7 @@ .dir-locals-2.el # Haskell -dist-newstyle/ \ No newline at end of file +dist-newstyle/ + +# direnv +.direnv diff --git a/default.nix b/default.nix deleted file mode 100644 index 9484e51..0000000 --- a/default.nix +++ /dev/null @@ -1,22 +0,0 @@ -{ sources ? import ./nix/sources.nix -, pkgs ? import sources.nixpkgs { } -}: -let - overrides = self: super: { - examples = self.callCabal2nix "examples" ./examples {}; - glpk-headers = self.callCabal2nix "glpk-headers" ./glpk-headers {}; - math-programming = self.callCabal2nix "math-programming" ./math-programming {}; - math-programming-glpk = self.callCabal2nix "math-programming-glpk" ./math-programming-glpk {}; - math-programming-tests = self.callCabal2nix "math-programming-tests" ./math-programming-tests {}; - }; - hPkgs = pkgs.haskellPackages.override { inherit overrides; }; -in -with hPkgs; -{ inherit - examples - glpk-headers - math-programming - math-programming-glpk - math-programming-tests - ; -} diff --git a/examples/examples.cabal b/examples/examples.cabal index 1e9a161..1c96642 100644 --- a/examples/examples.cabal +++ b/examples/examples.cabal @@ -23,12 +23,12 @@ executable sudoku default-language: Haskell2010 ghc-options: -threaded -pgmL markdown-unlit build-depends: base <5 - , containers ^>=0.6 - , markdown-unlit ^>=0.5 - , math-programming ^>=0.5 - , math-programming-glpk ^>=0.5 - , mtl ^>=2.2 - , text ^>=1.2 + , containers >=0.6 + , markdown-unlit >=0.5 + , math-programming >=0.5 + , math-programming-glpk >=0.5 + , mtl >=2.2 + , text >=1.2 executable 3sat main-is: Example3SAT.lhs @@ -36,12 +36,12 @@ executable 3sat default-language: Haskell2010 ghc-options: -threaded -pgmL markdown-unlit build-depends: base <5 - , containers ^>=0.6 - , markdown-unlit ^>=0.5 - , math-programming ^>=0.5 - , math-programming-glpk ^>=0.5 - , mtl ^>=2.2 - , text ^>=1.2 + , containers >=0.6 + , markdown-unlit >=0.5 + , math-programming >=0.5 + , math-programming-glpk >=0.5 + , mtl >=2.2 + , text >=1.2 executable tutorial @@ -50,9 +50,9 @@ executable tutorial default-language: Haskell2010 ghc-options: -threaded -pgmL markdown-unlit build-depends: base <5 - , containers ^>=0.6 - , markdown-unlit ^>=0.5 - , math-programming ^>=0.5 - , math-programming-glpk ^>=0.5 - , mtl ^>=2.2 - , text ^>=1.2 + , containers >=0.6 + , markdown-unlit >=0.5 + , math-programming >=0.5 + , math-programming-glpk >=0.5 + , mtl >=2.2 + , text >=1.2 diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a7c723d --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704763363, + "narHash": "sha256-W27aZBfns65R8vVB+n+lPncQqni4DSlCkWjKfhdFjCc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63c4175cb0fb03cab301d7ba058e4937bec464e2", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "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 index 0000000..a366e3e --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "A collection of libraries for mathematical programming"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + haskellPackages = pkgs.haskellPackages.override { + overrides = self: super: { + examples = self.callCabal2nix "examples" ./examples {}; + glpk-headers = self.callCabal2nix "glpk-headers" ./glpk-headers {}; + math-programming = self.callCabal2nix "math-programming" ./math-programming {}; + math-programming-glpk = self.callCabal2nix "math-programming-glpk" ./math-programming-glpk {}; + math-programming-tests = self.callCabal2nix "math-programming-tests" ./math-programming-tests {}; + }; + }; + in + { + packages.examples = haskellPackages.examples; + packages.glpk-headers = haskellPackages.glpk-headers; + packages.math-programming = haskellPackages.mathProgramming; + packages.math-programming-glpk = haskellPackages.mathProgrammingGlpk; + packages.math-programming-tests = haskellPackages.mathProgrammingTests; + packages.default = self.packages.${system}.examples; + defaultPackage = self.packages.${system}.default; + devShells.default = pkgs.haskellPackages.shellFor { + packages = p: [ haskellPackages.examples + haskellPackages.glpk-headers + haskellPackages.math-programming + haskellPackages.math-programming-glpk + haskellPackages.math-programming-tests + ]; + buildInputs = [ + pkgs.haskellPackages.haskell-language-server + pkgs.ormolu + pkgs.cabal-install + ]; + withHoogle = true; + doBenchmark = true; + }; + devShell = self.devShells.${system}.default; + } + ); +} diff --git a/math-programming-glpk/math-programming-glpk.cabal b/math-programming-glpk/math-programming-glpk.cabal index ffd6b06..bc38fba 100644 --- a/math-programming-glpk/math-programming-glpk.cabal +++ b/math-programming-glpk/math-programming-glpk.cabal @@ -24,12 +24,12 @@ library other-modules: Math.Programming.Glpk.Internal ghc-options: -Wall build-depends: base <5 - , glpk-headers ^>=0.5 - , math-programming ^>=0.5 - , mtl ^>=2.2 - , text ^>=1.2 - , transformers ^>=0.5 - , unliftio ^>=0.2 + , glpk-headers >=0.5 + , math-programming >=0.5 + , mtl >=2.2 + , text >=1.2 + , transformers >=0.5 + , unliftio >=0.2 test-suite math-programming-glpk-test-suite default-language: Haskell2010 @@ -40,7 +40,7 @@ test-suite math-programming-glpk-test-suite ghc-options: -threaded -with-rtsopts=-N -Wall build-depends: math-programming-glpk , base <5 - , math-programming ^>=0.5 - , math-programming-tests ^>=0.5 - , unliftio ^>=0.2 + , math-programming >=0.5 + , math-programming-tests >=0.5 + , unliftio >=0.2 , hspec >=2.8 && < 3 diff --git a/math-programming-tests/math-programming-tests.cabal b/math-programming-tests/math-programming-tests.cabal index 688a827..62570eb 100644 --- a/math-programming-tests/math-programming-tests.cabal +++ b/math-programming-tests/math-programming-tests.cabal @@ -28,13 +28,13 @@ library other-modules: ghc-options: -Wall build-depends: base <5 - , containers ^>=0.6 - , math-programming ^>=0.5 - , microlens ^>=0.4 - , microlens-th ^>=0.4 - , microlens-mtl ^>=0.2 + , containers >=0.6 + , math-programming >=0.5 + , microlens >=0.4 + , microlens-th >=0.4 + , microlens-mtl >=0.2 , hspec >=2.8 && <3 - , QuickCheck ^>=2.14 - , random ^>=1.2 - , mtl ^>=2.2 - , text ^>=1.2 + , QuickCheck >=2.14 + , random >=1.2 + , mtl >=2.2 + , text >=1.2 diff --git a/math-programming/math-programming.cabal b/math-programming/math-programming.cabal index 444973a..b6a24a7 100644 --- a/math-programming/math-programming.cabal +++ b/math-programming/math-programming.cabal @@ -28,11 +28,11 @@ library ghc-options: -Wall -- Restrictions on transformers due to https://hub.darcs.net/ross/transformers/issue/90 build-depends: base <5 - , containers ^>=0.6 - , exceptions ^>=0.10 - , mtl ^>=2.2 - , text ^>=1.2 - , transformers ^>=0.5 + , containers >=0.6 + , exceptions >=0.10 + , mtl >=2.2 + , text >=1.2 + , transformers >=0.5 test-suite math-programming-test-suite default-language: Haskell2010 @@ -45,6 +45,6 @@ test-suite math-programming-test-suite build-depends: math-programming , base <5 , hspec >=2.8 && <3 - , mtl ^>=2.2 - , QuickCheck ^>=2.14 - , text ^>=1.2 + , mtl >=2.2 + , QuickCheck >=2.14 + , text >=1.2 diff --git a/shell.nix b/shell.nix index 2525c7e..1371435 100644 --- a/shell.nix +++ b/shell.nix @@ -1,19 +1 @@ -{ sources ? import ./nix/sources.nix -, pkgs ? import sources.nixpkgs { } -}: -let - local = import ./default.nix { inherit sources pkgs; }; -in -pkgs.haskellPackages.shellFor { - packages = p: [ local.examples - local.glpk-headers - local.math-programming - local.math-programming-glpk - local.math-programming-tests - ]; - buildInputs = [ pkgs.cabal-install - pkgs.cabal2nix - pkgs.haskell-language-server - ]; - withHoogle = true; -} +(builtins.getFlake (builtins.toString ./.)).outputs.devShells.${builtins.currentSystem}