From 1134e373a3cfede41142261feeec88faeddc6702 Mon Sep 17 00:00:00 2001 From: Jeff Hutchison Date: Sun, 4 Feb 2024 10:40:15 -0500 Subject: [PATCH] Filter src input to derivation --- admin/flake.nix | 21 ++++---- admin/justfile | 4 +- daemon/flake.lock | 127 +++------------------------------------------- daemon/flake.nix | 13 +++-- web/flake.lock | 16 ++++++ web/flake.nix | 20 ++++++-- 6 files changed, 64 insertions(+), 137 deletions(-) diff --git a/admin/flake.nix b/admin/flake.nix index 30621d4..bfe0db3 100644 --- a/admin/flake.nix +++ b/admin/flake.nix @@ -22,19 +22,20 @@ deadeye-admin = mkPoetryApplication { projectDir = self; }; default = self.packages.${system}.deadeye-admin; - venv = mkPoetryEnv - { - projectDir = self; - groups = [ "main" "dev" ]; - }; + venv = mkPoetryEnv { + projectDir = self; + groups = [ "main" "dev" ]; + }; - dockerImage = pkgs.dockerTools.streamLayeredImage { + dockerImage = pkgs.dockerTools.buildLayeredImage { name = "j3ff/deadeye-admin"; tag = "latest"; - contents = [ - self.packages.${system}.deadeye-admin.dependencyEnv - ]; - config.Cmd = [ "/bin/deadeye-server" ]; + + config.Cmd = + let + deadeyePkg = self.packages.${system}.deadeye-admin.dependencyEnv; + in + [ "${deadeyePkg}/bin/deadeye-server" ]; }; }; diff --git a/admin/justfile b/admin/justfile index 097c457..638d960 100644 --- a/admin/justfile +++ b/admin/justfile @@ -8,7 +8,7 @@ VERSION := `git rev-parse --short HEAD` docker: nix build .#dockerImage - ./result | docker load + docker load < result docker tag {{ IMAGE }}:latest {{ IMAGE }}:{{VERSION}} run: docker @@ -17,6 +17,6 @@ run: docker deploy: docker docker push {{ IMAGE }}:{{VERSION}} - + venv: nix build .#venv -o .venv diff --git a/daemon/flake.lock b/daemon/flake.lock index 811effd..76203cf 100644 --- a/daemon/flake.lock +++ b/daemon/flake.lock @@ -18,42 +18,18 @@ "type": "github" } }, - "flake-utils_2": { - "inputs": { - "systems": "systems_2" - }, + "nix-filter": { "locked": { - "lastModified": 1694529238, - "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", + "lastModified": 1705332318, + "narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=", "owner": "numtide", - "repo": "flake-utils", - "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", + "repo": "nix-filter", + "rev": "3449dc925982ad46246cfc36469baf66e1b64f17", "type": "github" }, "original": { "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "nix-github-actions": { - "inputs": { - "nixpkgs": [ - "poetry2nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1698974481, - "narHash": "sha256-yPncV9Ohdz1zPZxYHQf47S8S0VrnhV7nNhCawY46hDA=", - "owner": "nix-community", - "repo": "nix-github-actions", - "rev": "4bb5e752616262457bc7ca5882192a564c0472d2", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "nix-github-actions", + "repo": "nix-filter", "type": "github" } }, @@ -73,48 +49,11 @@ "type": "github" } }, - "nixpkgs_2": { - "locked": { - "lastModified": 1699838902, - "narHash": "sha256-gtaGIer0Fg7QUvsUFsKIjrns32lhnd+o6FvIyokzcKQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "6c986b681d6b35affcc4eda42db63595ab01860e", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "master", - "repo": "nixpkgs", - "type": "github" - } - }, - "poetry2nix": { - "inputs": { - "flake-utils": "flake-utils_2", - "nix-github-actions": "nix-github-actions", - "nixpkgs": "nixpkgs_2", - "systems": "systems_3", - "treefmt-nix": "treefmt-nix" - }, - "locked": { - "lastModified": 1705060653, - "narHash": "sha256-puYyylgrBS4AFAHeyVRTjTUVD8DZdecJfymWJe7H438=", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "e0b44e9e2d3aa855d1dd77b06f067cd0e0c3860d", - "type": "github" - }, - "original": { - "id": "poetry2nix", - "type": "indirect" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "poetry2nix": "poetry2nix" + "nix-filter": "nix-filter", + "nixpkgs": "nixpkgs" } }, "systems": { @@ -131,56 +70,6 @@ "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" - } - }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "id": "systems", - "type": "indirect" - } - }, - "treefmt-nix": { - "inputs": { - "nixpkgs": [ - "poetry2nix", - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1699786194, - "narHash": "sha256-3h3EH1FXQkIeAuzaWB+nK0XK54uSD46pp+dMD3gAcB4=", - "owner": "numtide", - "repo": "treefmt-nix", - "rev": "e82f32aa7f06bbbd56d7b12186d555223dc399d1", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "treefmt-nix", - "type": "github" - } } }, "root": "root", diff --git a/daemon/flake.nix b/daemon/flake.nix index cad3453..aa9acc8 100644 --- a/daemon/flake.nix +++ b/daemon/flake.nix @@ -2,15 +2,17 @@ description = "Deadeye vision pipeline daemon"; inputs = { - flake-utils.url = "github:numtide/flake-utils"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + nix-filter.url = "github:numtide/nix-filter"; }; - outputs = { self, nixpkgs, flake-utils, poetry2nix }: + outputs = { self, nixpkgs, flake-utils, nix-filter }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; + filter = nix-filter.lib; in { packages = { @@ -28,7 +30,10 @@ { pname = "deadeye-daemon"; version = "22.2.0"; - src = self; + src = filter { + root = self; + include = [ ./src ./cmake "CMakeLists.txt" "version.cmake" ]; + }; nativeBuildInputs = with pkgs; [ cmake @@ -66,6 +71,8 @@ }; + default = self.packages.${system}.deadeye-daemon; + dockerImage = pkgs.dockerTools.buildLayeredImage { name = "j3ff/deadeye-daemon"; tag = "latest"; diff --git a/web/flake.lock b/web/flake.lock index 0257058..67923bc 100644 --- a/web/flake.lock +++ b/web/flake.lock @@ -18,6 +18,21 @@ "type": "github" } }, + "nix-filter": { + "locked": { + "lastModified": 1705332318, + "narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=", + "owner": "numtide", + "repo": "nix-filter", + "rev": "3449dc925982ad46246cfc36469baf66e1b64f17", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "nix-filter", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1705677747, @@ -37,6 +52,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "nix-filter": "nix-filter", "nixpkgs": "nixpkgs" } }, diff --git a/web/flake.nix b/web/flake.nix index dcc11a9..f4cbfaa 100644 --- a/web/flake.nix +++ b/web/flake.nix @@ -1,16 +1,20 @@ { + description = "Deadeye vision system admin dashboard"; + inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; + nix-filter.url = "github:numtide/nix-filter"; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, nix-filter }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; version = "22.2.0"; nodeDependencies = (pkgs.callPackage config/default.nix { }).nodeDependencies; + filter = nix-filter.lib; in { packages.nodeDependencies = nodeDependencies; @@ -18,7 +22,18 @@ packages.deadeye-web = pkgs.stdenv.mkDerivation { pname = "deadeye-web"; inherit version; - src = ./.; + src = filter { + root = self; + include = [ + ./config + "nginx.conf" + "package.json" + "package-lock.json" + "postcss.config.js" + ./public + ./src + ]; + }; buildInputs = with pkgs; [ nodejs_18 ]; @@ -71,7 +86,6 @@ packages.default = self.packages.${system}.deadeye-web; - # devShells.default = pkgs.mkShell { packages = with pkgs; [ just nodejs_18 node2nix ]; };