diff --git a/flake.lock b/flake.lock index 5dabf156..7b36f3c4 100644 --- a/flake.lock +++ b/flake.lock @@ -153,16 +153,15 @@ ] }, "locked": { - "lastModified": 1678737103, - "narHash": "sha256-9rUxd1Rx0bEBZb95fCUHnqWQfLgbACoZv0pyOSXuT40=", + "lastModified": 1678787322, + "narHash": "sha256-aJhChYdaotatK8hK8l12bDelaQvjBuL8QXoStrNN8VM=", "owner": "chvp", "repo": "devshell", - "rev": "0168d9deca2cb7e24d58e5356b6dfe3896338d0e", + "rev": "ff366c0283ba7b4702fb7ac471a06a4c91aa9b02", "type": "github" }, "original": { "owner": "chvp", - "ref": "background-services", "repo": "devshell", "type": "github" } diff --git a/flake.nix b/flake.nix index 782a0135..b268494a 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; devshell = { - url = "github:chvp/devshell/background-services"; + url = "github:chvp/devshell"; inputs = { flake-utils.follows = "flake-utils"; nixpkgs.follows = "nixpkgs"; @@ -98,6 +98,7 @@ input = nixpkgs; patches = builtins.map (patch: ./patches + "/${patch}") (builtins.filter (x: x != ".keep") (builtins.attrNames (builtins.readDir ./patches))); overlaysBuilder = _: [ + agenix.overlays.default accentor.overlays.default devshell.overlays.default emacs-overlay.overlay diff --git a/shells/dodona.nix b/shells/dodona.nix index 5e3d1340..e12b03ff 100644 --- a/shells/dodona.nix +++ b/shells/dodona.nix @@ -30,15 +30,22 @@ pkgs.devshell.mkShell { yarn ]; env = [ - { name = "CC"; value = "cc"; } - { name = "CPP"; value = "cpp"; } - { name = "CXX"; value = "c++"; } { name = "DATABASE_URL"; value = "mysql2://root:dodona@127.0.0.1:3306/dodona"; } { name = "TEST_DATABASE_URL"; value = "mysql2://root:dodona@127.0.0.1:3306/dodona_test"; } { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } { name = "PATH"; prefix = "$GEM_HOME/bin"; } ]; commands = [ + { + name = "refresh-deps"; + category = "general commands"; + help = "Install dependencies"; + command = '' + yarn install + bundle install + bundle pristine + ''; + } { name = "memcached"; category = "general commands"; diff --git a/shells/gamification2.nix b/shells/gamification2.nix index e2de6295..06bfa0c5 100644 --- a/shells/gamification2.nix +++ b/shells/gamification2.nix @@ -1,24 +1,23 @@ { pkgs, inputs }: pkgs.devshell.mkShell { name = "Gamification 2"; imports = [ "${inputs.devshell}/extra/language/c.nix" ]; - packages = with pkgs; [ - (pkgs.lowPrio binutils) - findutils - cmake - gnumake - nodejs - postgresql_14 - ruby_3_1 - yarn - ]; env = [ - { name = "NIX_CC"; value = "${pkgs.gcc}"; } - { name = "PGDATA"; eval = "$PRJ_DATA_DIR/postgres"; } { name = "DATABASE_HOST"; eval = "$PGDATA"; } { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } { name = "PATH"; prefix = "$GEM_HOME/bin"; } + { name = "PGDATA"; eval = "$PRJ_DATA_DIR/postgres"; } ]; commands = [ + { + name = "refresh-deps"; + category = "general commands"; + help = "Install dependencies"; + command = '' + yarn install + bundle install + bundle pristine + ''; + } { name = "pg:setup"; category = "database"; @@ -36,15 +35,7 @@ help = "Start postgres instance"; command = '' [ ! -d $PGDATA ] && pg:setup - pg_ctl -D $PGDATA -U postgres start -l log/postgres.log - ''; - } - { - name = "pg:stop"; - category = "database"; - help = "Stop postgres instance"; - command = '' - pg_ctl -D $PGDATA -U postgres stop + postgres ''; } { @@ -52,10 +43,24 @@ category = "database"; help = "Open database console"; command = '' - psql --host $PGDATA -U postgres + psql --host $PGDATA s ''; } ]; + packages = with pkgs; [ + (pkgs.lowPrio binutils) + findutils + cmake + gnumake + nodejs + postgresql_14 + ruby_3_1 + yarn + ]; + serviceGroups.server.services = { + web.command = "rails s -p 3000"; + postgres.command = "pg:start"; + }; language.c = { compiler = pkgs.gcc; includes = [ pkgs.zlib pkgs.openssl ]; diff --git a/shells/nixos-config.nix b/shells/nixos-config.nix index 0e79eb51..71c0f072 100644 --- a/shells/nixos-config.nix +++ b/shells/nixos-config.nix @@ -1,10 +1,23 @@ { pkgs, inputs }: pkgs.devshell.mkShell { name = "NixOS config"; + commands = [ + { + name = "format-all"; + category = "general commands"; + help = "Format all nix files in the project"; + command = "find $PRJ_ROOT -type f -name '*.nix' -print0 | xargs -0 nixpkgs-fmt"; + } + { + name = "fetchpatch"; + category = "general commands"; + help = "Fetch a patch from a nixpkgs PR by its ID"; + command = "curl -L https://github.com/NixOS/nixpkgs/pull/$1.patch -o $PRJ_ROOT/patches/$1.patch"; + } + ]; packages = [ + pkgs.agenix # Use nixos-rebuild from flake, since it might be patched pkgs.nixos-rebuild pkgs.nixpkgs-fmt - (pkgs.writeShellScriptBin "fetchpatch" "curl -L https://github.com/NixOS/nixpkgs/pull/$1.patch -o patches/$1.patch") - inputs.agenix.packages.${pkgs.system}.default ]; } diff --git a/shells/scriptingtalen-project.nix b/shells/scriptingtalen-project.nix deleted file mode 100644 index 52467016..00000000 --- a/shells/scriptingtalen-project.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ pkgs, ... }: pkgs.devshell.mkShell { - name = "Scriptingtalen project"; - packages = with pkgs; [ (python3.withPackages (ps: with ps; [ beautifulsoup4 requests ])) ]; -} diff --git a/shells/tab.nix b/shells/tab.nix index 44aabe97..f42ea60e 100644 --- a/shells/tab.nix +++ b/shells/tab.nix @@ -1,6 +1,27 @@ { pkgs, inputs }: pkgs.devshell.mkShell { name = "Tab"; imports = [ "${inputs.devshell}/extra/language/c.nix" ]; + commands = [ + { + name = "refresh-deps"; + category = "general commands"; + help = "Install dependencies"; + command = '' + yarn install + bundle install + bundle pristine + ''; + } + ]; + env = [ + { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } + { name = "PATH"; prefix = "$GEM_HOME/bin"; } + ]; + serviceGroups.server.services = { + web.command = "rails s -p 3000"; + js.command = "yarn build:dev --watch"; + css.command = "yarn build:css --watch"; + }; packages = with pkgs; [ (pkgs.lowPrio binutils) findutils @@ -9,29 +30,6 @@ nodejs yarn ]; - env = [ - { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } - { name = "PATH"; prefix = "$GEM_HOME/bin"; } - ]; - commands = [ - { - name = "server-support"; - category = "general commands"; - help = "Run everything required for a server"; - command = '' - bundle install - ''; - } - { - name = "server"; - category = "general commands"; - help = "Run everything"; - command = '' - server-support - rails s - ''; - } - ]; language.c = { compiler = pkgs.gcc; includes = [ pkgs.sqlite pkgs.libmysqlclient pkgs.zlib ]; diff --git a/shells/tap.nix b/shells/tap.nix index 6956d597..b1852c1c 100644 --- a/shells/tap.nix +++ b/shells/tap.nix @@ -1,6 +1,22 @@ { pkgs, inputs }: pkgs.devshell.mkShell { name = "Tap"; imports = [ "${inputs.devshell}/extra/language/c.nix" ]; + commands = [ + { + name = "refresh-deps"; + category = "general commands"; + help = "Install dependencies"; + command = '' + yarn install + bundle install + bundle pristine + ''; + } + ]; + env = [ + { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } + { name = "PATH"; prefix = "$GEM_HOME/bin"; } + ]; packages = with pkgs; [ (pkgs.lowPrio binutils) imagemagick @@ -11,32 +27,10 @@ nodejs yarn ]; - env = [ - { name = "CC"; value = "cc"; } - { name = "CPP"; value = "cpp"; } - { name = "CXX"; value = "c++"; } - { name = "GEM_HOME"; eval = "$PRJ_DATA_DIR/bundle/$(ruby -e 'puts RUBY_VERSION')"; } - { name = "PATH"; prefix = "$GEM_HOME/bin"; } - ]; - commands = [ - { - name = "server-support"; - category = "general commands"; - help = "Run everything required for a server"; - command = '' - bundle install - ''; - } - { - name = "server"; - category = "general commands"; - help = "Run everything"; - command = '' - server-support - rails s - ''; - } - ]; + serviceGroups.server.services.rails = { + name = "server"; + command = "rails s -p 3000"; + }; language.c = { compiler = pkgs.gcc; includes = [ pkgs.sqlite pkgs.libmysqlclient pkgs.zlib ];