From 5cff649141adbc141274875cc16af3912561c25b Mon Sep 17 00:00:00 2001 From: Mats Rauhala Date: Mon, 15 Nov 2021 20:50:03 +0200 Subject: [PATCH] Enable flakes support --- flake.lock | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 46 +++++++++++++++++++++++++++++++++ shell.nix | 43 ++++++------------------------- 3 files changed, 129 insertions(+), 35 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..e46f8a3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,75 @@ +{ + "nodes": { + "easy-hls-src": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1636606878, + "narHash": "sha256-rLxYl7iYP9vQhSvVlV2uRCdgrqKDz/vN1Z8ZmA8itkM=", + "owner": "jkachmar", + "repo": "easy-hls-nix", + "rev": "edd5710946d46ea40810ef9a708b084d7e05a118", + "type": "github" + }, + "original": { + "owner": "jkachmar", + "repo": "easy-hls-nix", + "type": "github" + } + }, + "flake-utils": { + "locked": { + "lastModified": 1634851050, + "narHash": "sha256-N83GlSGPJJdcqhUxSCS/WwW5pksYf3VP1M13cDRTSVA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c91f3de5adaf1de973b797ef7485e441a65b8935", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1636983198, + "narHash": "sha256-ductPDqewBTMB0ZWSJo3wc99RaR6MzbRf6wjWsMjqoM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d04b41c582c69405f1fb1272711967f777cca883", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1636979576, + "narHash": "sha256-Iy2J3T7xyHk43cVj4gGv74MKvVOCOqoqzffO3k5mbpU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4ea0167baf7126e424edb7ed2be27c0f6008dafb", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "easy-hls-src": "easy-hls-src", + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..559ad3f --- /dev/null +++ b/flake.nix @@ -0,0 +1,46 @@ +{ + description = "FeedMonad"; + + inputs = { + easy-hls-src = { url = "github:jkachmar/easy-hls-nix"; }; + flake-utils = { url = "github:numtide/flake-utils"; }; + }; + + outputs = { self, nixpkgs, flake-utils, easy-hls-src }: + flake-utils.lib.eachSystem ["x86_64-linux" "x86_64-darwin"] ( system: + let + pkgs = nixpkgs.legacyPackages.${system}; + hp = pkgs.haskellPackages.extend (self: super: { + FeedMonad = self.callPackage ./FeedMonad {}; + FeedMonad-demo = self.callPackage ./FeedMonad-demo {}; + }); + easy-hls = pkgs.callPackage easy-hls-src { ghcVersions = [ hp.ghc.version ]; }; + in + rec { + + packages = { inherit (hp) FeedMonad FeedMonad-demo; }; + + defaultPackage = packages.FeedMonad; + apps.FeedMonad-demo = { + type = "app"; + program = "${hp.FeedMonad-demo}/bin/FeedMonad-demo"; + }; + devShell = hp.shellFor { + packages = h: [h.FeedMonad h.FeedMonad-demo]; + withHoogle = true; + buildInputs = with pkgs; [ + entr + cabal-install + hp.hlint + stylish-haskell + ghcid + easy-hls + + sqlite-interactive + + hp.graphmod + ]; + }; + } + ); +} diff --git a/shell.nix b/shell.nix index c0ff229..c44a522 100644 --- a/shell.nix +++ b/shell.nix @@ -1,35 +1,8 @@ -{ nixpkgs ? import {} }: - -with nixpkgs; - -let - easy-hls-src = fetchFromGitHub { - owner = "ssbothwell"; - repo = "easy-hls-nix"; - inherit (builtins.fromJSON (builtins.readFile ./easy-hls-nix.json)) rev sha256; - }; - easy-hls = callPackage easy-hls-src { ghcVersions = [ hp.ghc.version ]; }; - hp = haskellPackages.extend (self: super: { - FeedMonad = self.callPackage ./FeedMonad {}; - FeedMonad-demo = self.callPackage ./FeedMonad-demo {}; - }); - -in - -hp.shellFor { - packages = h: [h.FeedMonad h.FeedMonad-demo]; - withHoogle = true; - buildInputs = [ - entr - cabal-install - haskellPackages.hlint - stylish-haskell - ghcid - easy-hls - - sqlite-interactive - - haskellPackages.graphmod - ]; -} - +# https://nixos.wiki/wiki/Flakes#Using_flakes_project_from_a_legacy_Nix +(import ( + fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz"; + sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2"; } +) { + src = ./.; +}).defaultNix