mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 05:02:10 +00:00
optimize flake shape and add devshell
This commit is contained in:
parent
f3d61787f0
commit
6dfef30594
8 changed files with 202 additions and 121 deletions
163
flake.nix
163
flake.nix
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
|
||||
nix-darwin = {
|
||||
url = "github:nix-darwin/nix-darwin/master";
|
||||
|
|
@ -24,7 +25,6 @@
|
|||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
|
||||
agentcomputer-cli = {
|
||||
url = "path:/Users/rathi/Documents/GitHub/companion/agentcomputer/apps/cli";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
|
@ -44,96 +44,99 @@
|
|||
};
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
self,
|
||||
nixpkgs,
|
||||
nix-darwin,
|
||||
home-manager,
|
||||
claudeCode,
|
||||
nix-homebrew,
|
||||
...
|
||||
}: let
|
||||
darwinSystem = "aarch64-darwin";
|
||||
linuxSystem = "x86_64-linux";
|
||||
username = "rathi";
|
||||
darwinConfigName = "darwin";
|
||||
darwinMachineHostname = "hari-macbook-pro";
|
||||
linuxConfigName = "netty";
|
||||
linuxHostname = "netty";
|
||||
darwinPkgs = import nixpkgs {system = darwinSystem;};
|
||||
linuxPkgs = import nixpkgs {
|
||||
system = linuxSystem;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
in {
|
||||
formatter.${darwinSystem} = darwinPkgs.alejandra;
|
||||
formatter.${linuxSystem} = linuxPkgs.alejandra;
|
||||
outputs =
|
||||
inputs@{
|
||||
self,
|
||||
flake-parts,
|
||||
nixpkgs,
|
||||
nix-darwin,
|
||||
home-manager,
|
||||
nix-homebrew,
|
||||
...
|
||||
}:
|
||||
let
|
||||
username = "rathi";
|
||||
hosts = import ./lib/hosts.nix { inherit username; };
|
||||
|
||||
darwinConfigurations.${darwinConfigName} = nix-darwin.lib.darwinSystem {
|
||||
system = darwinSystem;
|
||||
specialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = darwinMachineHostname;
|
||||
};
|
||||
modules = [
|
||||
./hosts/${darwinConfigName}
|
||||
home-manager.darwinModules.home-manager
|
||||
nix-homebrew.darwinModules.nix-homebrew
|
||||
{
|
||||
users.users.${username}.home = "/Users/${username}";
|
||||
mkPkgs =
|
||||
system:
|
||||
import nixpkgs {
|
||||
inherit system;
|
||||
config.allowUnfree = true;
|
||||
};
|
||||
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = darwinMachineHostname;
|
||||
};
|
||||
home-manager.backupFileExtension = "hm-bak";
|
||||
home-manager.users.${username} = import ./home;
|
||||
|
||||
nix-homebrew = {
|
||||
enable = true;
|
||||
enableRosetta = true;
|
||||
user = username;
|
||||
autoMigrate = true;
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
nixosConfigurations.${linuxConfigName} = nixpkgs.lib.nixosSystem {
|
||||
system = linuxSystem;
|
||||
specialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = linuxHostname;
|
||||
};
|
||||
modules = [
|
||||
inputs.disko.nixosModules.disko
|
||||
./hosts/${linuxConfigName}/configuration.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
mkHomeManagerModule =
|
||||
host:
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.extraSpecialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = linuxHostname;
|
||||
hostname = host.hostname;
|
||||
};
|
||||
home-manager.backupFileExtension = "hm-bak";
|
||||
home-manager.users.${username} = import ./home/netty.nix;
|
||||
}
|
||||
home-manager.users.${username} = import host.homeModule;
|
||||
};
|
||||
in
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = [
|
||||
hosts.darwin.system
|
||||
hosts.netty.system
|
||||
];
|
||||
};
|
||||
|
||||
# Standalone Home Manager config (fallback for non-NixOS Linux)
|
||||
homeConfigurations.${linuxConfigName} = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = linuxPkgs;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = linuxConfigName;
|
||||
};
|
||||
modules = [
|
||||
./hosts/${linuxConfigName}
|
||||
imports = [
|
||||
./modules/devshells.nix
|
||||
];
|
||||
|
||||
flake = {
|
||||
darwinConfigurations.${hosts.darwin.name} = nix-darwin.lib.darwinSystem {
|
||||
system = hosts.darwin.system;
|
||||
specialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = hosts.darwin.hostname;
|
||||
};
|
||||
modules = [
|
||||
./hosts/${hosts.darwin.name}
|
||||
home-manager.darwinModules.home-manager
|
||||
nix-homebrew.darwinModules.nix-homebrew
|
||||
{
|
||||
users.users.${username}.home = hosts.darwin.homeDirectory;
|
||||
|
||||
nix-homebrew = {
|
||||
enable = true;
|
||||
enableRosetta = true;
|
||||
user = username;
|
||||
autoMigrate = true;
|
||||
};
|
||||
}
|
||||
(mkHomeManagerModule hosts.darwin)
|
||||
];
|
||||
};
|
||||
|
||||
nixosConfigurations.${hosts.netty.name} = nixpkgs.lib.nixosSystem {
|
||||
system = hosts.netty.system;
|
||||
specialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = hosts.netty.hostname;
|
||||
};
|
||||
modules = [
|
||||
inputs.disko.nixosModules.disko
|
||||
./hosts/${hosts.netty.name}/configuration.nix
|
||||
home-manager.nixosModules.home-manager
|
||||
(mkHomeManagerModule hosts.netty)
|
||||
];
|
||||
};
|
||||
|
||||
homeConfigurations.${hosts.netty.name} = home-manager.lib.homeManagerConfiguration {
|
||||
pkgs = mkPkgs hosts.netty.system;
|
||||
extraSpecialArgs = {
|
||||
inherit inputs self username;
|
||||
hostname = hosts.netty.hostname;
|
||||
};
|
||||
modules = [
|
||||
hosts.netty.standaloneHomeModule
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue