From c3be5b79ce3b4004f8b7448c9f524f7ccd59b581 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 3 Dec 2022 13:32:33 -0500 Subject: [PATCH] Separate out the app --- activate.nix | 32 ++++++++++++++++++++++++++++++++ flake.nix | 33 +++------------------------------ 2 files changed, 35 insertions(+), 30 deletions(-) create mode 100644 activate.nix diff --git a/activate.nix b/activate.nix new file mode 100644 index 0000000..54f6143 --- /dev/null +++ b/activate.nix @@ -0,0 +1,32 @@ +# A rough flake-parts module for activating the system +# +# TODO: Replace with deploy-rs or (new) nixinate +{ self, inputs, ... }: +{ + perSystem = { system, pkgs, lib, ... }: { + apps.default = + 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 + 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 + ''; + }; +} diff --git a/flake.nix b/flake.nix index f24a034..4bf7dc1 100644 --- a/flake.nix +++ b/flake.nix @@ -36,40 +36,13 @@ ./home ./nixos ./nix-darwin + ./activate.nix ]; - perSystem = { self', inputs', config, pkgs, lib, system, ... }: { + perSystem = { pkgs, ... }: { devShells.default = pkgs.mkShell { - buildInputs = with pkgs; [ - nixpkgs-fmt - # To enable webhint to analyze source files - nodejs - ]; + buildInputs = [ pkgs.nixpkgs-fmt ]; }; formatter = pkgs.nixpkgs-fmt; - apps.default = - 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 - 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 - ''; }; flake = let