summaryrefslogtreecommitdiffstats
path: root/flake.nix
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-07-08 14:25:15 +0200
committerMatthias Beyer <mail@beyermatthias.de>2023-07-08 15:29:53 +0200
commit08ada9bd7bb6728d836c06afce261cdc1f994667 (patch)
tree6728218262f9cf38b8a91cb1dfdc285c209ba120 /flake.nix
parent6737ee6fd193f27ad9edc4e799fd548383c1d3ab (diff)
Replace shell.nix with flake
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix69
1 files changed, 69 insertions, 0 deletions
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
+ ];
+ };
+ });
+}