From 98bf3ef0b174124d095f30f7fe0b60016d6ca461 Mon Sep 17 00:00:00 2001 From: Philipp Mandler Date: Mon, 13 Jan 2025 22:58:29 +0100 Subject: [PATCH] flake: add overlay --- flake.nix | 32 ++++++++++++++++++++++++++++++-- nix/pkgs/frontend.nix | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index b363c6d7..6c13f447 100644 --- a/flake.nix +++ b/flake.nix @@ -35,10 +35,38 @@ self, ... }: + { + overlays.default = (final: prev: + let + pkgs = prev; + lib = pkgs.lib; + in + { + transcribee-backend = import ./nix/pkgs/backend.nix { + inherit pkgs lib uv2nix pyproject-nix pyproject-build-systems; + python = prev.python311; + }; + + transcribee-frontend = import ./nix/pkgs/frontend.nix { + inherit pkgs lib; + + versionInfo = { + commitHash = if (self ? rev) then self.rev else self.dirtyRev; + commitDate = lib.readFile "${prev.runCommand "timestamp" { env.when = self.lastModified; } "echo -n `date -d @$when --iso-8601=s` > $out"}"; + }; + }; + }); + + nixosModules.default = { + nixpkgs.overlays = [ self.overlays.default ]; + }; + } // (flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; + pkgs = import nixpkgs { + inherit system; + }; lib = nixpkgs.lib; python = pkgs.python311; @@ -50,7 +78,7 @@ ]; in { - packages = rec { + packages = { worker = (import ./nix/pkgs/worker.nix { inherit pkgs lib python uv2nix pyproject-nix pyproject-build-systems; }); backend = (import ./nix/pkgs/backend.nix { inherit pkgs lib python uv2nix pyproject-nix pyproject-build-systems; }); frontend = (import ./nix/pkgs/frontend.nix { diff --git a/nix/pkgs/frontend.nix b/nix/pkgs/frontend.nix index a44234c7..e90f2aec 100644 --- a/nix/pkgs/frontend.nix +++ b/nix/pkgs/frontend.nix @@ -17,7 +17,7 @@ pkgs.buildNpmPackage (lib.fix (self: { gitDeps = (lib.attrsets.filterAttrs (name: pkgInfo: (lib.hasPrefix "node_modules/" name) && (lib.hasPrefix "git" (pkgInfo.resolved or ""))) - (pkgs.lib.importJSON (self.src + "/package-lock.json")).packages); + (lib.importJSON (self.src + "/package-lock.json")).packages); in lib.attrsets.mapAttrs (name: pkgInfo: let src = builtins.fetchGit {