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 --- flake.nix | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 flake.nix (limited to 'flake.nix') 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 + ]; + }; + }); +} -- cgit v1.2.3