From 08ada9bd7bb6728d836c06afce261cdc1f994667 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Jul 2023 14:25:15 +0200 Subject: Replace shell.nix with flake Signed-off-by: Matthias Beyer --- .gitignore | 1 + flake.lock | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 69 +++++++++++++++++ shell.nix | 17 ----- 4 files changed, 318 insertions(+), 17 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 47663e4..fd2fa87 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /themes/* blog-imports public +/result* diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4538a5f --- /dev/null +++ b/flake.lock @@ -0,0 +1,248 @@ +{ + "nodes": { + "check-flake": { + "locked": { + "lastModified": 1662502605, + "narHash": "sha256-jAT55UhabAxLAVGanxjnNdzH2/oX2ZjLsL4i2jPIP+g=", + "owner": "srid", + "repo": "check-flake", + "rev": "48a17393ed4fcd523399d6602c283775b5127295", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "check-flake", + "type": "github" + } + }, + "ema": { + "inputs": { + "check-flake": [ + "emanote", + "check-flake" + ], + "flake-parts": [ + "emanote", + "flake-parts" + ], + "flake-root": [ + "emanote", + "flake-root" + ], + "haskell-flake": [ + "emanote", + "haskell-flake" + ], + "nixpkgs": [ + "emanote", + "nixpkgs" + ], + "treefmt-nix": [ + "emanote", + "treefmt-nix" + ] + }, + "locked": { + "lastModified": 1678746319, + "narHash": "sha256-vOh7o0AK2PohGa1LPTAGIPmua1beR67XowEcaI8UPhg=", + "owner": "srid", + "repo": "ema", + "rev": "b46a08d7a26491b9801642ab9c13e94f929c6a90", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "ema", + "type": "github" + } + }, + "emanote": { + "inputs": { + "check-flake": "check-flake", + "ema": "ema", + "flake-parts": "flake-parts", + "flake-root": "flake-root", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1688491882, + "narHash": "sha256-b3hIpvCGTIWIOvkFJbkrBmlifF8JGVlOOJElE2NKKe0=", + "owner": "srid", + "repo": "emanote", + "rev": "d1dd7ea4ad89dc74f8d4b90650e07e788b489bb6", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "emanote", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1671710971, + "narHash": "sha256-YZdt5IJrfsdUTtVB94EMsBvaJbK9ve6QaZyzRuup+sY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "98bec08c58a9547d705f2f5e300ac8eef6665e52", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-root": { + "locked": { + "lastModified": 1671378805, + "narHash": "sha256-yqGxyzMN2GuppwG3dTWD1oiKxi+jGYP7D1qUSc5vKhI=", + "owner": "srid", + "repo": "flake-root", + "rev": "dc7ba6166e478804a9da6881aa48c45d300075cf", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1687709756, + "narHash": "sha256-Y5wKlQSkgEK2weWdOu4J3riRd+kV/VCgHsqLNTTWQ/0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "dbabf0ca0c0c4bce6ea5eaf65af5cb694d2082c7", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1685469326, + "narHash": "sha256-esxJLsGexI/J6Fc32tJd2p3K5IOBZSCHgFvegjIpc+0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "996f5c2cdc67285c4990df378976f9dbf26f8401", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1687245362, + "narHash": "sha256-+f9tH+k3u9lSS136M2LCsl5NJTNPvhmHEiVOcypiu1E=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "205ee073b053fc4d87d5adf2ebd44ebbef7bca4d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1671359686, + "narHash": "sha256-3MpC6yZo+Xn9cPordGz2/ii6IJpP2n8LE8e/ebUXLrs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "04f574a1c0fde90b51bf68198e2297ca4e7cccf4", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "emanote": "emanote", + "flake-utils": "flake-utils", + "nixpkgs": [ + "emanote", + "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" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "emanote", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1675588998, + "narHash": "sha256-CLeFLmah0mxNp/EIW0PMG3YutKxVIIs4B0f5oJhwe8E=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "70e03145e26c2f3199f4320ecd9fd343f1129c60", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ba4437a --- /dev/null +++ b/flake.nix @@ -0,0 +1,69 @@ +{ + description = "My knowledge"; + + nixConfig = { + extra-substituters = "https://srid.cachix.org"; + extra-trusted-public-keys = "srid.cachix.org-1:3clnql5gjbJNEvhA/WQp7nrZlBptwpXnUk6JAv8aB2M="; + }; + + inputs = { + emanote.url = "github:srid/emanote"; + nixpkgs.follows = "emanote/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, emanote, flake-utils, nixpkgs, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { inherit system; }; + in + rec { + apps.deploy = flake-utils.lib.mkApp { + name = "deploy"; + drv = pkgs.writeScriptBin "deploy" '' + #!${pkgs.runtimeShell} + rsync -arP ${packages.default}/public as:/srv/knowledge.beyermatthi.as/ + ''; + }; + + apps.serve = flake-utils.lib.mkApp { + name = "serve"; + drv = pkgs.writeScriptBin "serve" '' + #!${pkgs.runtimeShell} + PORT=8008 ${emanote.packages."${system}".default}/bin/emanote + ''; + }; + + packages.default = pkgs.stdenv.mkDerivation { + name = "knowledge"; + + src = + let + nixFilter = path: _type: !pkgs.lib.hasSuffix ".nix" path; + extraFiles = path: _type: !(builtins.any (n: pkgs.lib.hasSuffix n path) [ ".github" ".sh" ]); + filterPath = path: type: builtins.all (f: f path type) [ + nixFilter + extraFiles + pkgs.lib.cleanSourceFilter + ]; + in + pkgs.lib.cleanSourceWith { + src = ./.; + filter = filterPath; + }; + + buildPhase = '' + mkdir -p $out/public/ + ${emanote.packages."${system}".default}/bin/emanote --allow-broken-links gen $out/public/ + ''; + + installPhase = ''true''; + }; + + devShells.default = pkgs.mkShell { + buildInputs = [ + pkgs.nixpkgs-fmt + ]; + }; + }); +} diff --git a/shell.nix b/shell.nix deleted file mode 100644 index e2c2286..0000000 --- a/shell.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs ? (import {}) -, arch ? "x86_64-linux" }: - -let - emanote = import (pkgs.fetchFromGitHub { - owner = "srid"; - repo = "emanote"; - rev = "9f5990de035c05b94e084e50158047bbb69516a9"; - sha256 = "0n0jvrmms59pfv3dj2838xz563rpbk3xn3psbi74g590l2y89k4k"; - }); -in -pkgs.mkShell { - buildInputs = with pkgs; [ - emanote.outputs.defaultPackage.${arch} - ]; -} - -- cgit v1.2.3