From ce855bb3ae4dab1ed890636eac9bc17af7b55d78 Mon Sep 17 00:00:00 2001 From: Natsu Kagami Date: Tue, 26 Oct 2021 14:25:19 -0400 Subject: [PATCH] Set up flakes and nix-darwin --- .gitignore | 1 + darwin/configuration.nix | 30 ++++++++++++ fish/fish.nix | 4 +- flake.lock | 99 ++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++ macbook-home.nix | 4 +- 6 files changed, 165 insertions(+), 4 deletions(-) create mode 100644 darwin/configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 3de0997..e56b43d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ home.nix +/result diff --git a/darwin/configuration.nix b/darwin/configuration.nix new file mode 100644 index 0000000..1963af4 --- /dev/null +++ b/darwin/configuration.nix @@ -0,0 +1,30 @@ +{ config, pkgs, ... }: + +{ + # List packages installed in system profile. To search by name, run: + # $ nix-env -qaP | grep wget + environment.systemPackages = + [ pkgs.vim + ]; + + # Use a custom configuration.nix location. + # $ darwin-rebuild switch -I darwin-config=$HOME/.config/nixpkgs/darwin/configuration.nix + # environment.darwinConfig = "$HOME/.config/nixpkgs/darwin/configuration.nix"; + + # Auto upgrade nix package and the daemon service. + # services.nix-daemon.enable = true; + nix.package = pkgs.nixUnstable; + + # Create /etc/bashrc that loads the nix-darwin environment. + programs.zsh.enable = true; # default shell on catalina + # programs.fish.enable = true; + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + + users.users.nki = { + name = "nki"; + home = "/Users/nki"; + }; +} diff --git a/fish/fish.nix b/fish/fish.nix index 6034fa7..675d156 100644 --- a/fish/fish.nix +++ b/fish/fish.nix @@ -1,7 +1,7 @@ -{ config, pkgs, ... }: +{ config, pkgs, nixpkgs-unstable, ... }: let - pkgsUnstable = import {}; + pkgsUnstable = import nixpkgs-unstable { system = pkgs.system; }; in { programs.fish = { diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..2d02f58 --- /dev/null +++ b/flake.lock @@ -0,0 +1,99 @@ +{ + "nodes": { + "darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs-unstable" + ] + }, + "locked": { + "lastModified": 1634994402, + "narHash": "sha256-xmlCVVOYGpZoxgOqsDOVF0B0ASrnbNGVAEzID9qh2xo=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "44da835ac40dab5fd231298b59d83487382d2fab", + "type": "github" + }, + "original": { + "owner": "lnl7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1635123562, + "narHash": "sha256-kYuwQqHXDYxy5ijpm8SvCoPNx0br1TpoWeTIOEwOYvA=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "da8a78eec9f7adb57f9e961d1da64805efacff37", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1635268020, + "narHash": "sha256-oaWU7ZvobClXLrQGj7Xvjs2vSlItPFkw/usKh/2c56Y=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "89a27a2e6f54993224f804e50a29e48b8c83d1ca", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1635214691, + "narHash": "sha256-65D0Q6fAKzX3ZGlJSTZGj4jbIB7fttZ8FD754AOYeiQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "30f73c6493b4877753da54bfafd1aef90f0eebdf", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1622516815, + "narHash": "sha256-ZjBd81a6J3TwtlBr3rHsZspYUwT9OdhDk+a/SgSEf7I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "7e9b0dff974c89e070da1ad85713ff3c20b0ca97", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "21.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "darwin": "darwin", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..18347f5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,31 @@ +{ + description = "nki's darwin system"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/21.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + darwin.url = "github:lnl7/nix-darwin/master"; + darwin.inputs.nixpkgs.follows = "nixpkgs-unstable"; + home-manager.url = "github:nix-community/home-manager"; + }; + + outputs = { self, darwin, nixpkgs, nixpkgs-unstable, home-manager }: { + darwinConfigurations."nki-macbook" = darwin.lib.darwinSystem rec { + system = "aarch64-darwin"; + modules = [ + ./darwin/configuration.nix + home-manager.darwinModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = { inherit nixpkgs-unstable; }; + home-manager.users.nki = import ./macbook-home.nix; + } + ]; + inputs = { + inherit darwin nixpkgs-unstable; + nixpkgs = nixpkgs-unstable; + }; + }; + }; +} diff --git a/macbook-home.nix b/macbook-home.nix index 1480607..807e0b9 100644 --- a/macbook-home.nix +++ b/macbook-home.nix @@ -1,7 +1,7 @@ -{ config, pkgs, ... }: +{ config, pkgs, nixpkgs-unstable, ... }: let - x86pkgs = import { config.allowUnsupportedSystem = true; }; + x86pkgs = import nixpkgs-unstable { system = pkgs.system; config.allowUnsupportedSystem = true; }; in { imports = [ ./common.nix ];