Skip to content

Commit

Permalink
Simplify dev setup by moving commons to another flake
Browse files Browse the repository at this point in the history
  • Loading branch information
eikek committed Mar 12, 2024
1 parent 70044f9 commit 1dfa5e1
Show file tree
Hide file tree
Showing 13 changed files with 168 additions and 456 deletions.
73 changes: 71 additions & 2 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

161 changes: 69 additions & 92 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,130 +2,107 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-23.11";
flake-utils.url = "github:numtide/flake-utils";
devshell-tools.url = "github:eikek/devshell-tools";
};

outputs = inputs @ {
self,
nixpkgs,
flake-utils,
devshell-tools,
}:
{
overlays.default = final: prev: {
solr = self.packages.${prev.system}.solr;
openapi-doc = self.packages.${prev.system}.openapi-doc;
};
nixosConfigurations = let
selfOverlay = {
lib,
config,
...
}: {
nixpkgs.overlays = [
self.overlays.default
];
system.stateVersion = "23.11";
};
in {
dev-vm = nixpkgs.lib.nixosSystem {
nixosConfigurations = {
rsdev-vm = devshell-tools.lib.mkVm {
system = flake-utils.lib.system.x86_64-linux;
specialArgs = {inherit inputs;};
modules = [
selfOverlay
./nix/dev-vm.nix
./nix/services.nix
];
};

container = nixpkgs.lib.nixosSystem {
rsdev-cnt = devshell-tools.lib.mkContainer {
system = flake-utils.lib.system.x86_64-linux;
modules = [
({pkgs, ...}: {
boot.isContainer = true;
networking.useDHCP = false;
})
selfOverlay
./nix/solr-module.nix
./nix/services.nix
];
};
};
}
// flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
selfPkgs = self.packages.${system};
selfPkgs = import ./nix/dev-scripts.nix {
inherit system devshell-tools;
inherit (pkgs) writeShellScriptBin;
};
devshellToolsPkgs = devshell-tools.packages.${system};
commonPackages = with pkgs;
[
redis
jq
scala-cli
devshellToolsPkgs.sbt17
devshellToolsPkgs.openapi-docs
]
++ (builtins.attrValues selfPkgs);

queueNames = [
"projectCreated"
"projectUpdated"
"projectRemoved"
"projectAuthorizationAdded"
"projectAuthorizationUpdated"
"projectAuthorizationRemoved"
"userAdded"
"userUpdated"
];
queueNameConfig = builtins.listToAttrs (builtins.map (qn: {
name = "RS_REDIS_QUEUE_${qn}";
value = qn;
})
queueNames);
in {
formatter = pkgs.alejandra;
packages =
((import ./nix/dev-scripts.nix) {inherit (pkgs) concatTextFile writeShellScriptBin;})
// rec {
solr = pkgs.callPackage (import ./nix/solr.nix) {};
swagger-ui = pkgs.callPackage (import ./nix/swagger-ui.nix) {};
openapi-doc = pkgs.callPackage (import ./nix/openapi-doc.nix) {inherit swagger-ui;};
};

devShells = rec {
default = container;
container = pkgs.mkShell {
RS_SOLR_HOST = "rsdev";
RS_SOLR_URL = "http://rsdev:8983/solr";
RS_SOLR_CORE = "rsdev-test";
RS_REDIS_HOST = "rsdev";
RS_REDIS_PORT = "6379";
RS_CONTAINER = "rsdev";
RS_LOG_LEVEL = "3";

#don't start docker container for dbTests
NO_SOLR = "true";
NO_REDIS = "true";
container = pkgs.mkShellNoCC (queueNameConfig
// {
RS_SOLR_HOST = "rsdev-cnt";
RS_SOLR_URL = "http://rsdev-cnt:8983/solr";
RS_SOLR_CORE = "rsdev-test";
RS_REDIS_HOST = "rsdev-cnt";
RS_REDIS_PORT = "6379";
RS_CONTAINER = "rsdev";
RS_LOG_LEVEL = "3";

buildInputs = with pkgs;
with selfPkgs; [
redis
jq
sbt
scala-cli
#don't start docker container for dbTests
NO_SOLR = "true";
NO_REDIS = "true";
DEV_CONTAINER = "rsdev-cnt";

redis-push
recreate-container
start-container
solr-create-core
solr-delete-core
solr-recreate-core
solr-recreate-dbtests-cores
solr-logs
k8s-reprovision
];
};
vm = pkgs.mkShell {
RS_SOLR_URL = "http://localhost:18983/solr";
RS_SOLR_CORE = "rsdev-test";
RS_REDIS_HOST = "localhost";
RS_REDIS_PORT = "16379";
VM_SSH_PORT = "10022";
RS_LOG_LEVEL = "3";
buildInputs =
commonPackages
++ (builtins.attrValues devshell-tools.legacyPackages.${system}.cnt-scripts);
});
vm = pkgs.mkShellNoCC (queueNameConfig
// {
RS_SOLR_URL = "http://localhost:18983/solr";
RS_SOLR_CORE = "rsdev-test";
RS_REDIS_HOST = "localhost";
RS_REDIS_PORT = "16379";
VM_SSH_PORT = "10022";
RS_LOG_LEVEL = "3";

#don't start docker container for dbTests
NO_SOLR = "true";
NO_REDIS = "true";
#don't start docker container for dbTests
NO_SOLR = "true";
NO_REDIS = "true";

buildInputs = with pkgs;
with selfPkgs; [
redis
jq
sbt
scala-cli
DEV_VM = "rsdev-vm";

redis-push
vm-build
vm-run
vm-ssh
vm-solr-create-core
vm-solr-delete-core
vm-solr-recreate-core
vm-solr-logs
solr-recreate-dbtests-cores
k8s-reprovision
];
};
buildInputs =
commonPackages
++ (builtins.attrValues devshell-tools.legacyPackages.${system}.vm-scripts);
});
};
});
}
Loading

0 comments on commit 1dfa5e1

Please sign in to comment.