From 8de45a9f3e89ac76ea169d4b8323a1949720de44 Mon Sep 17 00:00:00 2001 From: Matthias Meschede Date: Wed, 16 Aug 2023 19:09:46 +0200 Subject: [PATCH 1/2] switch to nix flake and new nixpkgs --- default.nix | 27 +++++++----------- flake.lock | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 39 ++++++++++++++++++++++++++ shell.nix | 23 +++++++--------- 4 files changed, 138 insertions(+), 30 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/default.nix b/default.nix index 329ba2d..2cccff2 100644 --- a/default.nix +++ b/default.nix @@ -1,17 +1,10 @@ -{ compiler ? null -, pkgs ? import {} -}: - -let - haskellPackages = - if builtins.isNull compiler - then pkgs.haskellPackages - else pkgs.haskell.packages.${compiler}; - overriddenPackages = haskellPackages.override { - overrides = self: super: { - taskwarrior = - self.callPackage ./taskwarrior.nix {}; - }; - }; -in - overriddenPackages.callCabal2nix "hasknote" ./. {} +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).defaultNix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..754f2e4 --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1689068808, + "narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "flake": false, + "locked": { + "lastModified": 1688392541, + "narHash": "sha256-lHrKvEkCPTUO+7tPfjIcb7Trk6k31rz18vkyqmkeJfY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "ea4c80b39be4c09702b0cb3b42eab59e2ba4f24b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-compat": "flake-compat", + "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..1c158c5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "A very basic flake"; + + inputs = { + flake-compat = { + url = "github:edolstra/flake-compat"; + flake = false; + }; + nixpkgs = { + url = "github:NixOS/nixpkgs/release-22.11"; + flake = false; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, flake-compat, nixpkgs, flake-utils }: + + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + haskellPackages = pkgs.haskellPackages; + overriddenPackages = haskellPackages.override { + overrides = self: super: { + hasknote = self.callCabal2nix "hasknote" ./. { }; + }; + }; + in { + packages.default = overriddenPackages.hasknote; + devShells.default = overriddenPackages.shellFor { + packages = p: [ p.hasknote ]; + buildInputs = with pkgs.haskellPackages; [ + cabal-install + haskell-language-server + hls-splice-plugin + hls-eval-plugin + ]; + }; + }); +} diff --git a/shell.nix b/shell.nix index 459c181..6234bb4 100644 --- a/shell.nix +++ b/shell.nix @@ -1,13 +1,10 @@ -let - pkgs = (import ./pinned-packages.nix).pkgs1909; - drv = import ./. { inherit pkgs; }; -in - pkgs.haskellPackages.shellFor { - packages = p: [drv]; - buildInputs = with pkgs.haskellPackages; [ - cabal-install - ghcid - stylish-haskell - hlint - ]; - } +(import + ( + let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz"; + sha256 = lock.nodes.flake-compat.locked.narHash; + } + ) + { src = ./.; } +).shellNix From 9fb8fefa27a4bbe0aa5fe38985bfc20bca914c73 Mon Sep 17 00:00:00 2001 From: Matthias Meschede Date: Wed, 16 Aug 2023 19:39:55 +0200 Subject: [PATCH 2/2] fix all issues with new haskell-taskwarrior version --- hasknote.cabal | 1 + src/Main.hs | 5 +++-- taskwarrior.nix | 21 --------------------- 3 files changed, 4 insertions(+), 23 deletions(-) delete mode 100644 taskwarrior.nix diff --git a/hasknote.cabal b/hasknote.cabal index 9cb11f6..2d5fb59 100644 --- a/hasknote.cabal +++ b/hasknote.cabal @@ -34,6 +34,7 @@ executable hasknote build-depends: aeson , base , config-ini + , containers , data-default , directory , filepath diff --git a/src/Main.hs b/src/Main.hs index fa3fe26..8cc0373 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -23,6 +23,7 @@ import qualified Data.Ini.Config as Ini import Data.Text (Text) import qualified Data.Text as T import qualified Data.Text.IO as TIO +import qualified Data.Set as Set import Data.Time (UTCTime, getCurrentTime) import qualified Data.UUID as UUID @@ -254,7 +255,7 @@ removeAnnotation :: Text -> Task -> Task removeAnnotation prefix task = task { Task.annotations = - filter + Set.filter ((/=prefix) . T.take (T.length prefix) . Annot.description) (Task.annotations task) } @@ -263,7 +264,7 @@ addAnnotation :: Text -> UTCTime -> Task -> Task addAnnotation description entryTime task = task { Task.annotations = - Annot.Annotation entryTime description : Task.annotations task + Set.insert (Annot.Annotation entryTime description) (Task.annotations task) } expandPath :: FilePath -> IO FilePath diff --git a/taskwarrior.nix b/taskwarrior.nix deleted file mode 100644 index dcf7e38..0000000 --- a/taskwarrior.nix +++ /dev/null @@ -1,21 +0,0 @@ -{ mkDerivation, aeson, base, bytestring, hspec, hspec-discover -, process, QuickCheck, quickcheck-instances, random, stdenv -, string-interpolate, text, time, unordered-containers, uuid -}: -mkDerivation { - pname = "taskwarrior"; - version = "0.1.2.0"; - sha256 = "972b4f4d070fd2174935a88a58f6d8d5b371fb1f1b6dbae921ccadd4c6a2b5ce"; - libraryHaskellDepends = [ - aeson base bytestring process random string-interpolate text time - unordered-containers uuid - ]; - testHaskellDepends = [ - aeson base hspec QuickCheck quickcheck-instances text time - unordered-containers uuid - ]; - testToolDepends = [ hspec-discover ]; - homepage = "https://github.com/maralorn/haskell-taskwarrior"; - description = "Types and aeson instances for taskwarrior tasks"; - license = stdenv.lib.licenses.agpl3Plus; -}