From 107b261411be81237e8f43f6bf588d8da0d1ca60 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Tue, 7 Jun 2022 22:32:57 -0400 Subject: [PATCH] nix: Refactor --- flake.nix | 14 +++---- nix/docker.nix | 54 +++++++++++++-------------- nix/{flake-module.nix => emanote.nix} | 0 nix/home-manager-module.nix | 2 +- 4 files changed, 33 insertions(+), 37 deletions(-) rename nix/{flake-module.nix => emanote.nix} (100%) diff --git a/flake.nix b/flake.nix index 513cf9162..7b642fd64 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,7 @@ systems = nixpkgs.lib.systems.flakeExposed; imports = [ haskell-flake.flakeModule - ./nix/flake-module.nix + ./nix/emanote.nix ./nix/docker.nix ]; perSystem = { pkgs, inputs', self', ... }: { @@ -55,12 +55,10 @@ tailwind; }; }; - packages = - { - test = pkgs.runCommand "emanote-test" { } '' - ${pkgs.lib.getExe self'.packages.default} --test 2>&1 | tee $out - ''; - }; + packages.test = + pkgs.runCommand "emanote-test" { } '' + ${pkgs.lib.getExe self'.packages.default} --test 2>&1 | tee $out + ''; emanote = { package = self'.packages.default; sites = { @@ -74,7 +72,7 @@ }; flake = { homeManagerModule = import ./nix/home-manager-module.nix; - flakeModule = import ./nix/flake-module.nix; + flakeModule = import ./nix/emanote.nix; }; }; } diff --git a/nix/docker.nix b/nix/docker.nix index de3dea0fc..8cbd3da3a 100644 --- a/nix/docker.nix +++ b/nix/docker.nix @@ -1,35 +1,33 @@ # Add a package for docker image on Linux. -{ self, config, lib, flake-parts-lib, ... }: +{ ... }: { - options = { - perSystem = flake-parts-lib.mkPerSystemOption - ({ config, self', inputs', pkgs, system, ... }: { - packages = pkgs.lib.optionalAttrs (system == "x86_64-linux") - { - dockerImage = pkgs.dockerTools.buildImage - { - name = "sridca/emanote"; - tag = "latest"; - contents = [ - self'.packages.default - # These are required for the GitLab CI runner - pkgs.coreutils - pkgs.bash_5 - ]; - - config = { - WorkingDir = "/data"; - Volumes = { - "/data" = { }; - }; - Tmpfs = { - "/tmp" = { }; - }; - Cmd = [ "${pkgs.lib.getExe self'.packages.default}" ]; + config = { + perSystem = { config, self', inputs', pkgs, system, ... }: { + packages = pkgs.lib.optionalAttrs (system == "x86_64-linux") + { + dockerImage = pkgs.dockerTools.buildImage + { + name = "sridca/emanote"; + tag = "latest"; + contents = [ + self'.packages.default + # These are required for the GitLab CI runner + pkgs.coreutils + pkgs.bash_5 + ]; + config = { + WorkingDir = "/data"; + Volumes = { + "/data" = { }; + }; + Tmpfs = { + "/tmp" = { }; }; + Cmd = [ "${pkgs.lib.getExe self'.packages.default}" ]; }; - }; - }); + }; + }; + }; }; } diff --git a/nix/flake-module.nix b/nix/emanote.nix similarity index 100% rename from nix/flake-module.nix rename to nix/emanote.nix diff --git a/nix/home-manager-module.nix b/nix/home-manager-module.nix index 2b7005be8..fe8295241 100644 --- a/nix/home-manager-module.nix +++ b/nix/home-manager-module.nix @@ -51,7 +51,7 @@ in ''; }; - # TODO: Consolidate all these options below with those of flake-module.nix + # TODO: Consolidate all these options below with those of nix/emanote.nix host = mkOption { type = types.str;