From 5c448dce0990c15be6d07c9f616183e900fe8dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20P=C3=A4tzel?= Date: Wed, 26 Apr 2023 15:40:05 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Swap=20to=20simpler=20Nix=20flak?= =?UTF-8?q?e=E2=80=93based=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- default.nix | 23 ++++++++++++----------- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ haga.cabal | 24 ++++++++++++++++++------ haga.md | 17 +++++++++++++++++ haga.org | 3 ++- run | 5 +++-- 7 files changed, 103 insertions(+), 20 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 haga.md diff --git a/default.nix b/default.nix index a849063..24749d8 100644 --- a/default.nix +++ b/default.nix @@ -1,7 +1,7 @@ -{ mkDerivation, base, Cabal, extra, monad-loops, MonadRandom -, optparse-applicative, pipes, protolude, QuickCheck -, quickcheck-instances, random, random-fu, random-shuffle, stdenv -, text +{ mkDerivation, base, Cabal, cassava, extra, lib, monad-loops +, MonadRandom, optparse-applicative, pipes, protolude, QuickCheck +, quickcheck-instances, random, random-fu, random-shuffle, text +, wl-pprint-text }: mkDerivation { pname = "haga"; @@ -10,15 +10,16 @@ mkDerivation { isLibrary = true; isExecutable = true; libraryHaskellDepends = [ - base extra monad-loops MonadRandom optparse-applicative pipes - protolude QuickCheck quickcheck-instances random random-fu - random-shuffle text + base cassava extra monad-loops MonadRandom optparse-applicative + pipes protolude QuickCheck quickcheck-instances random random-fu + random-shuffle text wl-pprint-text ]; executableHaskellDepends = [ - base Cabal extra monad-loops MonadRandom optparse-applicative pipes - protolude QuickCheck quickcheck-instances random random-fu - random-shuffle text + base Cabal cassava extra monad-loops MonadRandom + optparse-applicative pipes protolude QuickCheck + quickcheck-instances random random-fu random-shuffle text + wl-pprint-text ]; description = "Simplistic genetic algorithms library"; - license = stdenv.lib.licenses.gpl3; + license = lib.licenses.gpl3Only; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..84bc2a5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1655624069, + "narHash": "sha256-7g1zwTdp35GMTERnSzZMWJ7PG3QdDE8VOX3WsnOkAtM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0d68d7c857fe301d49cdcd56130e0beea4ecd5aa", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..51509eb --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "Flake for haga"; + inputs = { + nixpkgs.url = + # 2022-06-22 + "github:NixOS/nixpkgs/0d68d7c857fe301d49cdcd56130e0beea4ecd5aa"; + + }; + + outputs = inputs@{ self, nixpkgs }: + with import nixpkgs { + system = "x86_64-linux"; + }; { + # defaultPackage.${system} = haskellPackages.callPackage ./default.nix { }; + devShell.${system} = mkShell { + buildInputs = [ + feedgnuplot + haskellPackages.cabal-install + haskellPackages.ormolu + haskell.compiler.ghc8107 + ]; + }; + }; +} diff --git a/haga.cabal b/haga.cabal index a162acb..b9fca91 100644 --- a/haga.cabal +++ b/haga.cabal @@ -20,7 +20,8 @@ category: Optimization build-type: Simple library - build-depends: base ^>=4.13.0.0 + build-depends: base ^>=4.14.0.0 + , cassava , extra , MonadRandom , monad-loops @@ -30,9 +31,11 @@ library , QuickCheck , quickcheck-instances , random - , random-fu + -- 0.3.0.0 introduces at least one truly breaking change. + , random-fu <0.3.0.0 , random-shuffle , text + , wl-pprint-text default-language: Haskell2010 ghc-options: -Wall -Wno-name-shadowing -Wno-orphans hs-source-dirs: src @@ -40,9 +43,12 @@ library , Seminar , Pretty , Szenario191 + , Szenario202 + , Analysis executable haga - build-depends: base ^>=4.13.0.0 + build-depends: base ^>=4.14.0.0 + , cassava , extra , MonadRandom , monad-loops @@ -52,9 +58,11 @@ executable haga , QuickCheck , quickcheck-instances , random - , random-fu + -- 0.3.0.0 introduces at least one truly breaking change. + , random-fu <0.3.0.0 , random-shuffle , text + , wl-pprint-text default-language: Haskell2010 ghc-options: -Wall -Wno-name-shadowing -Wno-orphans hs-source-dirs: src @@ -63,9 +71,11 @@ executable haga , Seminar , Pretty , Szenario191 + , Szenario202 executable haga-test - build-depends: base ^>=4.13.0.0 + build-depends: base ^>=4.14.0.0 + , cassava , Cabal , extra , MonadRandom @@ -76,9 +86,11 @@ executable haga-test , QuickCheck , quickcheck-instances , random - , random-fu + -- 0.3.0.0 introduces at least one truly breaking change. + , random-fu <0.3.0.0 , random-shuffle , text + , wl-pprint-text default-language: Haskell2010 ghc-options: -Wall -Wno-name-shadowing -Wno-orphans hs-source-dirs: src diff --git a/haga.md b/haga.md new file mode 100644 index 0000000..c454eed --- /dev/null +++ b/haga.md @@ -0,0 +1,17 @@ +# Building + + +``` +nix develop +cabal update +cabal build +``` + + +# Running + + +``` +nix develop +fish run +``` diff --git a/haga.org b/haga.org index 81d339a..4b31533 100644 --- a/haga.org +++ b/haga.org @@ -1,11 +1,12 @@ * PROJECT haga -** TODO see TODOs in code +** TODO See TODOs in code ** MAYBE Add factory floor optimizer GA that optimizes factory floor - data: graph of workstations with edge weights being the number of walks between them - desired: optimal configuration that reduces crossings - space: 15 workstations that can be positioned in a 20 x 20 space +** MAYBE Implement simple lcs in haga * Unsorted ideas - https://github.com/mikeizbicki/HerbiePlugin - https://github.com/mikeizbicki/subhask diff --git a/run b/run index 846a085..fde2fe5 100755 --- a/run +++ b/run @@ -1,9 +1,10 @@ #! /usr/bin/env nix-shell -#! nix-shell -i fish -p fish feedgnuplot + set exe (fd --type f '^haga$' dist-newstyle/) -"$exe" $argv | \ + +"$exe" --iterations=10000 $argv | \ # dist-newstyle/build/x86_64-linux/ghc-8.6.5/ga-0.1.0.0/x/ga/build/ga/ga $argv | \ feedgnuplot \ --terminal "x11 background '#ffffff'" \