Skip to content

Commit

Permalink
nix: Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
srid committed Jun 8, 2022
1 parent 2495852 commit 107b261
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
14 changes: 6 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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', ... }: {
Expand Down Expand Up @@ -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 = {
Expand All @@ -74,7 +72,7 @@
};
flake = {
homeManagerModule = import ./nix/home-manager-module.nix;
flakeModule = import ./nix/flake-module.nix;
flakeModule = import ./nix/emanote.nix;
};
};
}
54 changes: 26 additions & 28 deletions nix/docker.nix
Original file line number Diff line number Diff line change
@@ -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}" ];
};
};
});
};
};
};
};
}
File renamed without changes.
2 changes: 1 addition & 1 deletion nix/home-manager-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 107b261

Please sign in to comment.