diff --git a/README.md b/README.md index 2714e70..57106b5 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,8 @@ A [flake-parts](https://flake.parts/) module to unify [NixOS](https://nixos.org/manual/nixos/stable/) + [nix-darwin](https://github.com/LnL7/nix-darwin) + [home-manager] configuration in a single flake, while providing a consistent interface (and enabling common modules) for both Linux and macOS. For motivation, see https://community.flake.parts/nixos-flake - [home-manager]: https://github.com/nix-community/home-manager - - ## Getting Started https://community.flake.parts/nixos-flake/start diff --git a/doc/examples.md b/doc/examples.md index c9ee0cc..4e07753 100644 --- a/doc/examples.md +++ b/doc/examples.md @@ -2,8 +2,8 @@ order: 10 --- -# Examples +# Examples -- https://github.com/srid/nixos-config (using `#both` [[templates|template]]) +- https://github.com/srid/nixos-config (using both `#macos` & `#linux` [[templates|template]]) - https://github.com/juspay/nix-dev-home (using `#home` [[templates|template]]) - https://github.com/hkmangla/nixos (using `#linux` [[templates|template]]) diff --git a/doc/start.md b/doc/start.md index c924436..0d49c13 100644 --- a/doc/start.md +++ b/doc/start.md @@ -23,6 +23,4 @@ For a more automated way to install NixOS, see [nixos-anywhere](https://github.c ## macOS 1. [Install Nix](https://nixos.asia/en/install) -1. Use the [[templates|macOS only template]][^both] - -[^both]: Alternatively, use the "Both platforms" [[templates|template]] if you are sharing your configuration with the other platform as well. +1. Use the [[templates|macOS only template]] diff --git a/doc/templates.md b/doc/templates.md index 70f0c4e..16966d6 100644 --- a/doc/templates.md +++ b/doc/templates.md @@ -8,15 +8,6 @@ You can easily initialize one of our templates using [Omnix](https://omnix.page/ [^no-omnix]: If you do not use Omnix, you must use `nix flake init`, and manually change the template values such as username and hostname. -{#both} -### Both platforms - -NixOS, nix-darwin, [home-manager] configuration combined, with common modules. - -```bash -nix --accept-flake-config run github:juspay/omnix -- \ - init -o ~/nix-config github:srid/nixos-flake#both -``` {#nixos} ### NixOS only diff --git a/examples/both/flake.nix b/examples/both/flake.nix deleted file mode 100644 index edf721b..0000000 --- a/examples/both/flake.nix +++ /dev/null @@ -1,130 +0,0 @@ -{ - inputs = { - # Principle inputs (updated by `nix run .#update`) - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nix-darwin.url = "github:lnl7/nix-darwin/master"; - nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - - flake-parts.url = "github:hercules-ci/flake-parts"; - nixos-flake.url = "github:srid/nixos-flake"; - }; - - outputs = inputs@{ self, ... }: - inputs.flake-parts.lib.mkFlake { inherit inputs; } { - systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; - imports = [ - inputs.nixos-flake.flakeModule - ]; - - flake = - let - myUserName = "john"; - in - { - # Configurations for Linux (NixOS) machines - nixosConfigurations = { - # TODO: Replace this hostname! - "linux-host" = self.nixos-flake.lib.mkLinuxSystem { - nixpkgs.hostPlatform = "x86_64-linux"; - imports = [ - self.nixosModules.common # See below for "nixosModules"! - self.nixosModules.linux - # Your machine's configuration.nix goes here - ({ pkgs, ... }: { - # TODO: Put your /etc/nixos/hardware-configuration.nix here - boot.loader.grub.device = "nodev"; - fileSystems."/" = { - device = "/dev/disk/by-label/nixos"; - fsType = "btrfs"; - }; - system.stateVersion = "23.05"; - }) - # Your home-manager configuration - self.nixosModules.home-manager - { - home-manager.users.${myUserName} = { - imports = [ - self.homeModules.common # See below for "homeModules"! - self.homeModules.linux - ]; - home.stateVersion = "22.11"; - }; - } - ]; - }; - }; - - # Configurations for macOS machines - darwinConfigurations = { - # TODO: Replace this hostname! - "macos-host" = self.nixos-flake.lib.mkMacosSystem { - nixpkgs.hostPlatform = "aarch64-darwin"; - imports = [ - self.nixosModules.common # See below for "nixosModules"! - self.nixosModules.darwin - self.darwinModules_.nix-darwin - # Your machine's configuration.nix goes here - ({ pkgs, ... }: { - # https://github.com/nix-community/home-manager/issues/4026#issuecomment-1565487545 - users.users.${myUserName}.home = "/Users/${myUserName}"; - - # Used for backwards compatibility, please read the changelog before changing. - # $ darwin-rebuild changelog - system.stateVersion = 4; - }) - # Your home-manager configuration - self.darwinModules_.home-manager - { - home-manager.users.${myUserName} = { - imports = [ - self.homeModules.common # See below for "homeModules"! - self.homeModules.darwin - ]; - home.stateVersion = "22.11"; - }; - } - ]; - }; - }; - - # All nixos/nix-darwin configurations are kept here. - nixosModules = { - # Common nixos/nix-darwin configuration shared between Linux and macOS. - common = { pkgs, ... }: { - environment.systemPackages = with pkgs; [ - hello - ]; - }; - # NixOS specific configuration - linux = { pkgs, ... }: { - users.users.${myUserName}.isNormalUser = true; - services.netdata.enable = true; - }; - # nix-darwin specific configuration - darwin = { pkgs, ... }: { - security.pam.enableSudoTouchIdAuth = true; - }; - }; - - # All home-manager configurations are kept here. - homeModules = { - # Common home-manager configuration shared between Linux and macOS. - common = { pkgs, ... }: { - programs.git.enable = true; - programs.starship.enable = true; - programs.bash.enable = true; - }; - # home-manager config specific to NixOS - linux = { - xsession.enable = true; - }; - # home-manager config specifi to Darwin - darwin = { - targets.darwin.search = "Bing"; - }; - }; - }; - }; -} diff --git a/flake.nix b/flake.nix index 72cd4c9..920a367 100644 --- a/flake.nix +++ b/flake.nix @@ -7,11 +7,6 @@ tmplPath = path: builtins.path { inherit path; filter = path: _: baseNameOf path != "test.sh"; }; in rec { - default = both; - both = { - description = "nixos-flake template for both Linux and macOS in same flake"; - path = tmplPath ./examples/both; - }; linux = { description = "nixos-flake template for NixOS configuration.nix"; path = tmplPath ./examples/linux; @@ -39,11 +34,6 @@ ]; }; - both = { - template = templates.both; - inherit (home) params; - }; - macos = { template = templates.macos; params = home.params ++ [ @@ -77,10 +67,6 @@ dir = "examples/linux"; systems = [ "x86_64-linux" "aarch64-linux" ]; }; - both = { - inherit overrideInputs; - dir = "examples/both"; - }; }; }; };