From 550d0b96f61fd8c445276d8bbd0f8cd167975c8a Mon Sep 17 00:00:00 2001 From: thedavidmeister Date: Tue, 7 Nov 2023 12:44:06 +0400 Subject: [PATCH] add nix flake --- flake.lock | 105 ++++++++++++++++++++++++++++++++++++++++++++++++- flake.nix | 27 ++++++++++++- pin/Dockerfile | 4 +- 3 files changed, 132 insertions(+), 4 deletions(-) diff --git a/flake.lock b/flake.lock index 5b20c3e..acd0c1b 100644 --- a/flake.lock +++ b/flake.lock @@ -18,7 +18,94 @@ "type": "github" } }, + "flake-utils_2": { + "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" + } + }, + "gildlab": { + "inputs": { + "flake-utils": "flake-utils_2", + "naersk": "naersk", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1699345862, + "narHash": "sha256-gwCIBdPmkivstG1lcVN/IzH6Ao+wiQOtor9ULz8uGDw=", + "owner": "gildlab", + "repo": "gildlab.cli", + "rev": "b45f0e1b2a783f0581c3e8cccd1b1756b49d1376", + "type": "github" + }, + "original": { + "owner": "gildlab", + "repo": "gildlab.cli", + "rev": "b45f0e1b2a783f0581c3e8cccd1b1756b49d1376", + "type": "github" + } + }, + "naersk": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1687852486, + "narHash": "sha256-2rXkhKUVQxbVaC+TITPpILiy/dSbordOLs87eoWHYxA=", + "owner": "nix-community", + "repo": "naersk", + "rev": "df10963b956962913b693a638746a95d6c506404", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "naersk", + "type": "github" + } + }, "nixpkgs": { + "locked": { + "lastModified": 1687793116, + "narHash": "sha256-6xRgZ2E9r/BNam87vMkHJ/0EPTTKzeNwhw3abKilEE4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9e4e0807d2142d17f463b26a8b796b3fe20a3011", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1687793116, + "narHash": "sha256-6xRgZ2E9r/BNam87vMkHJ/0EPTTKzeNwhw3abKilEE4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9e4e0807d2142d17f463b26a8b796b3fe20a3011", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1699343069, "narHash": "sha256-s7BBhyLA6MI6FuJgs4F/SgpntHBzz40/qV0xLPW6A1Q=", @@ -37,7 +124,8 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "gildlab": "gildlab", + "nixpkgs": "nixpkgs_3" } }, "systems": { @@ -54,6 +142,21 @@ "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" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 1267d14..3f2ca33 100644 --- a/flake.nix +++ b/flake.nix @@ -3,18 +3,43 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/ec750fd01963ab6b20ee1f0cb488754e8036d89d"; + gildlab.url = "github:gildlab/gildlab.cli/b45f0e1b2a783f0581c3e8cccd1b1756b49d1376"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, gildlab, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; + path = "$HOME/.config/gildlab/ipfs-node"; + ensure-home = '' + set -u + export GILDLAB_IPFS_NODE_BASE_PATH=${path} + mkdir -p ${path} + + mkdir -p ${path}/volumes/ipfs/data/ipfs + mkdir -p ${path}/volumes/ipfs/export + mkdir -p ${path}/volumes/pin + + mkdir -p ${path}/volumes/nginx + touch ${path}/.env + ''; + in rec { packages = rec { }; + + devShell = pkgs.mkShell rec { + buildInputs = [ + gildlab.defaultPackage.${system} + ]; + + shellHook = '' + ${ensure-home} + ''; + }; } ); } \ No newline at end of file diff --git a/pin/Dockerfile b/pin/Dockerfile index 6103200..3b2e426 100644 --- a/pin/Dockerfile +++ b/pin/Dockerfile @@ -1,7 +1,7 @@ -FROM nixos/nix:2.16.1 +FROM nixos/nix:2.18.1 # Get latest gildlab cli from main -RUN nix --extra-experimental-features "nix-command flakes" --print-build-logs profile install github:gildlab/gildlab-cli && nix-collect-garbage -d +RUN nix --extra-experimental-features "nix-command flakes" --print-build-logs profile install github:gildlab/gildlab.cli/b45f0e1b2a783f0581c3e8cccd1b1756b49d1376 && nix-collect-garbage -d RUN gildlab-cli --version ADD . .