diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index c4a847d..bdcb645 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +/.direnv/ /result diff --git a/README.markdown b/README.markdown index 751ace6..4060a8f 100644 --- a/README.markdown +++ b/README.markdown @@ -7,13 +7,13 @@ This repository contains files for building First, you should update the necessary Nix files: ``` bash -nix-shell --run 'bash generate.sh' +nix develop --command bash generate.sh ``` Afterwards, the distribution for financier can be built: ``` bash -nix-build dist.nix +nix build ``` There is also a module (module.nix) that you can use in your NixOS diff --git a/dist.nix b/dist.nix index efbae55..460be41 100644 --- a/dist.nix +++ b/dist.nix @@ -1,12 +1,11 @@ { pkgs ? import { inherit system; }, system ? builtins.currentSystem -}: +, financierVersion }: let financier = (import ./default.nix { inherit pkgs system; }).package; - meta = import ./meta.nix; in pkgs.stdenv.mkDerivation { - inherit (meta) version; + version = financierVersion; pname = "financier-dist"; src = "${financier}/lib/node_modules/financier"; buildInputs = [ financier.nodejs ]; diff --git a/flake.lock b/flake.lock index 06833b4..aeca13c 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "financier": { + "flake": false, + "locked": { + "lastModified": 1643285999, + "narHash": "sha256-t0fdmgXtL5oh1sORK/9Uv8lDFXW2GCkQg+LGWyo8mXw=", + "owner": "mpuppe", + "repo": "financier", + "rev": "feb17f4bfba2121043be68d6ab74573c6be2a06d", + "type": "gitlab" + }, + "original": { + "owner": "mpuppe", + "repo": "financier", + "type": "gitlab" + } + }, "flake-utils": { "locked": { "lastModified": 1631561581, @@ -31,6 +47,7 @@ }, "root": { "inputs": { + "financier": "financier", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index 6d47e5b..cb89d68 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,22 @@ { inputs.flake-utils.url = "github:numtide/flake-utils"; - outputs = { self, nixpkgs, flake-utils }: - let overlay = import ./overlay.nix; - in flake-utils.lib.eachDefaultSystem (system: + inputs.financier = { + url = "gitlab:mpuppe/financier"; + flake = false; + }; + + outputs = inputs@{ self, nixpkgs, ... }: + let + financierVersion = "1.7.3"; + nodeVersion = "12"; + + overlay = final: prev: { + financier-dist = import ./dist.nix { + inherit financierVersion; + inherit (prev) pkgs system; + }; + }; + in inputs.flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; @@ -11,8 +25,18 @@ in { packages = { inherit (pkgs) financier-dist; }; defaultPackage = self.packages.${system}.financier-dist; + devShell = pkgs.mkShell { + packages = with pkgs; [ nodePackages.node2nix ]; + shellHook = '' + export FINANCIER_SRC="${inputs.financier}" + export FINANCIER_NODE_VERSION="${nodeVersion}" + ''; + }; }) // { inherit overlay; - nixosModule = import ./module.nix; + nixosModule = { + imports = [ ./module.nix ]; + nixpkgs.overlays = [ self.overlay ]; + }; }; } diff --git a/helpers.nix b/helpers.nix index c109e48..dbeb77b 100644 --- a/helpers.nix +++ b/helpers.nix @@ -1,4 +1,12 @@ { - fetchFinancier = { fetchgit, meta ? import ./meta.nix }: - fetchgit { inherit (meta) url rev sha256; }; + fetchFinancier = { fetchgit }: + let + financierLockData = (builtins.fromJSON + (builtins.readFile ./flake.lock)).nodes.financier.locked; + inherit (financierLockData) narHash owner repo rev; + url = "https://gitlab.com/${owner}/${repo}.git"; + in fetchgit { + inherit url rev; + sha256 = narHash; + }; } diff --git a/meta.nix b/meta.nix deleted file mode 100644 index 142267b..0000000 --- a/meta.nix +++ /dev/null @@ -1,9 +0,0 @@ -rec { - version = "1.7.3"; - nodeVersion = "12"; - - # Arguments for fetchgit - url = "https://gitlab.com/mpuppe/financier.git"; - rev = "83367cae265af4a036a05766c6f80ea22d1cc1ec"; - sha256 = "0h7222j9fk4b3fkc7c6gbhl0xranpl5swapkwibb0aba0g6fykfg"; -} diff --git a/module.nix b/module.nix index 35b9086..cea1162 100644 --- a/module.nix +++ b/module.nix @@ -29,8 +29,6 @@ in { }; config = mkIf cfg.enable { - nixpkgs.overlays = [ (import ./overlay.nix) ]; - networking.firewall.allowedTCPPorts = [ 80 443 ]; services.nginx = mkIf (cfg.server == "nginx") { diff --git a/overlay.nix b/overlay.nix deleted file mode 100644 index 3a03727..0000000 --- a/overlay.nix +++ /dev/null @@ -1,3 +0,0 @@ -final: prev: { - financier-dist = import ./dist.nix { inherit (prev) pkgs system; }; -}