diff --git a/README.md b/README.md index c43f2e4..84b7a07 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ To build, ```sh # First, edit nixosConfigurations in flake.nix to add your system's hostname. # And then change `userName` to your username. -nix run +nix develop -c , activate ``` ## Install notes @@ -19,14 +19,14 @@ nix run - Clone this repo at `/etc/nixos` - Edit `flake.nix` to use your system hostname in the `nixosConfigurations` set - Edit `users/config.nix` to contain your users - - Run `nix run`. That's it. Re-open your shell. + - Run `nix develop -c , activate`. That's it. Re-open your shell. - macOS: - Install Nix normally (multi-user) - Install [nix-darwin](https://github.com/LnL7/nix-darwin) - This will create a `~/.nixpkgs/darwin-configuration.nix`, but we do not need that. - Clone this repo anywhere - Edit `users/config.nix` to contain your users - - Run `nix run`.[^cleanup] That's it. Re-open your shell. + - Run `nix develop -c , activate`.[^cleanup] That's it. Re-open your terminal. [^cleanup]: You might have to `rm -rf /etc/nix/nix.conf`, so our flake.nix can do its thing. @@ -45,6 +45,7 @@ nix run - You may also update a subset of inputs, e.g. ```sh-session nix flake lock --update-input nixpkgs --update-input darwin --update-input home-manager + # Also, in the dev shell: , update-primary ``` - To free up disk space, ```sh-session diff --git a/flake.lock b/flake.lock index 0148ad4..75dc4b4 100644 --- a/flake.lock +++ b/flake.lock @@ -79,11 +79,11 @@ ] }, "locked": { - "lastModified": 1671736733, - "narHash": "sha256-5Hbq4oZlsozOEyoOmJKqxbBeO/J8u89j3XZfavjsI3I=", + "lastModified": 1672336914, + "narHash": "sha256-Z4wNuBhHwBUwqhDx+j/2DQ5J7saXFuE+7yyDwfNklSE=", "owner": "hercules-ci", "repo": "nix-darwin", - "rev": "5311f8ded0bccf2a4e5fcafb75a240197c09b959", + "rev": "7ec26a9042ea3418798a5a486632da1c87826fd4", "type": "github" }, "original": { @@ -115,11 +115,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1671358416, - "narHash": "sha256-8AeYoYO7hQKIxjhLPurmHxPZBk6Fx1WrF6/omkWedWQ=", + "lastModified": 1672630914, + "narHash": "sha256-LVIJDR3gyk5RhBndzWuEhUz0OPKqtwyOnoSCSxY9mtw=", "owner": "nix-community", "repo": "emacs-overlay", - "rev": "d8baf8af22511e7526d9336eede54bbfa6aed13e", + "rev": "2fa6cca26891f696c13fe910bb659ecd69ed3842", "type": "github" }, "original": { @@ -255,6 +255,21 @@ "type": "github" } }, + "flake-root_2": { + "locked": { + "lastModified": 1671378805, + "narHash": "sha256-yqGxyzMN2GuppwG3dTWD1oiKxi+jGYP7D1qUSc5vKhI=", + "owner": "srid", + "repo": "flake-root", + "rev": "dc7ba6166e478804a9da6881aa48c45d300075cf", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "flake-root", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -361,11 +376,11 @@ "utils": "utils_2" }, "locked": { - "lastModified": 1671209729, - "narHash": "sha256-zxn1eA/rMi2DOx43V7q87bGaDzvL7CMVY/Ti7lJ92DQ=", + "lastModified": 1672349765, + "narHash": "sha256-Ul3lSGglgHXhgU3YNqsNeTlRH1pqxbR64h+2hM+HtnM=", "owner": "nix-community", "repo": "home-manager", - "rev": "7d55a72d4c1df694e87a41a7e6c9a7b6e9a40ca3", + "rev": "dd99675ee81fef051809bc87d67eb07f5ba022e8", "type": "github" }, "original": { @@ -374,6 +389,26 @@ "type": "github" } }, + "mission-control": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671493916, + "narHash": "sha256-7uvy37mfprmI3fbBw9E+baV1KZHR5zKfSNfPlSiliqo=", + "owner": "Platonic-Systems", + "repo": "mission-control", + "rev": "9acdaa469ebd3c2d6816f8a30c0c217a0da59fe2", + "type": "github" + }, + "original": { + "owner": "Platonic-Systems", + "repo": "mission-control", + "type": "github" + } + }, "naersk": { "inputs": { "nixpkgs": [ @@ -633,11 +668,11 @@ }, "nixpkgs_7": { "locked": { - "lastModified": 1671200928, - "narHash": "sha256-mZfzDyzojwj6I0wyooIjGIn81WtGVnx6+avU5Wv+VKU=", + "lastModified": 1672350804, + "narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=", "owner": "nixos", "repo": "nixpkgs", - "rev": "757b82211463dd5ba1475b6851d3731dfe14d377", + "rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6", "type": "github" }, "original": { @@ -678,8 +713,10 @@ "emacs-overlay": "emacs-overlay", "emanote": "emanote", "flake-parts": "flake-parts_2", + "flake-root": "flake-root_2", "hci": "hci", "home-manager": "home-manager", + "mission-control": "mission-control", "nix-serve-ng": "nix-serve-ng", "nixos-hardware": "nixos-hardware", "nixos-shell": "nixos-shell", diff --git a/flake.nix b/flake.nix index 6f49952..bb7020d 100644 --- a/flake.nix +++ b/flake.nix @@ -12,16 +12,19 @@ home-manager.url = "github:nix-community/home-manager"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; agenix.url = "github:ryantm/agenix"; + nixos-hardware.url = "github:NixOS/nixos-hardware"; # CI server hci.url = "github:hercules-ci/hercules-ci-agent"; nix-serve-ng.url = "github:aristanetworks/nix-serve-ng"; - # Supportive inputs - nixos-shell.url = "github:Mic92/nixos-shell"; - nixos-hardware.url = "github:NixOS/nixos-hardware"; + # Devshell inputs + mission-control.url = "github:Platonic-Systems/mission-control"; + mission-control.inputs.nixpkgs.follows = "nixpkgs"; + flake-root.url = "github:srid/flake-root"; # Software inputs + nixos-shell.url = "github:Mic92/nixos-shell"; nixos-vscode-server.url = "github:msteen/nixos-vscode-server"; nixos-vscode-server.flake = false; comma.url = "github:nix-community/comma"; @@ -47,6 +50,8 @@ ./home ./nixos ./nix-darwin + inputs.mission-control.flakeModule + inputs.flake-root.flakeModule ]; flake = { @@ -81,12 +86,12 @@ }; perSystem = { pkgs, config, inputs', ... }: { - devShells.default = pkgs.mkShell { + devShells.default = config.mission-control.installToDevShell (pkgs.mkShell { buildInputs = [ pkgs.nixpkgs-fmt inputs'.agenix.packages.agenix ]; - }; + }); formatter = pkgs.nixpkgs-fmt; apps.default = config.apps.activate; }; diff --git a/lib.nix b/lib.nix index 3d244f0..e300bbe 100644 --- a/lib.nix +++ b/lib.nix @@ -56,43 +56,34 @@ }; perSystem = { system, pkgs, lib, ... }: { - # TODO: replace these with mission-control - apps = - let - # Create a flake app that wraps the given bash CLI. - bashCmdApp = name: cmd: { - type = "app"; - program = - (pkgs.writeShellApplication { - inherit name; - text = '' - set -x - ${cmd} - ''; - }) + "/bin/${name}"; - }; - in - { - # A rough app for activating the system locally. - # - # TODO: Replace with deploy-rs or (new) nixinate - activate = + mission-control.scripts = { + update-primary = { + description = '' + Update primary flake inputs + ''; + exec = + let + inputs = [ "nixpkgs" "home-manager" "darwin" ]; + in + '' + nix flake lock ${lib.foldl' (acc: x: acc + " --update-input " + x) "" inputs} + ''; + }; + + activate = { + description = "Activate the current configuration for local system"; + exec = + # TODO: Replace with deploy-rs or (new) nixinate if system == "aarch64-darwin" then - bashCmdApp "darwin" '' + '' ${self.darwinConfigurations.default.system}/sw/bin/darwin-rebuild \ switch --flake ${self}#default '' else - bashCmdApp "linux" '' + '' ${lib.getExe pkgs.nixos-rebuild} --use-remote-sudo switch -j auto ''; - - update-primary = - let inputs = [ "nixpkgs" "home-manager" "darwin" ]; - in bashCmdApp "update-primary" '' - nix flake lock ${lib.foldl' (acc: x: acc + " --update-input " + x) "" inputs} - ''; - }; + }; }; }