From 2a4c93c86dae18f6eff59c5f0a5faca003b33557 Mon Sep 17 00:00:00 2001 From: David Crompton Date: Wed, 16 Aug 2023 15:02:44 -0400 Subject: [PATCH] Add Laptop Config --- flake.lock | 58 +++++++++++++++++--- flake.nix | 29 ++++++++-- machines/universeair/configuration.nix | 73 ++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 machines/universeair/configuration.nix diff --git a/flake.lock b/flake.lock index ad63023..6d7d232 100644 --- a/flake.lock +++ b/flake.lock @@ -1,17 +1,59 @@ { "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692099905, + "narHash": "sha256-/pSusGhmIdSdAaywQRFA5dVbfdIzlWQTecM+E46+cJ0=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "2a6679aa9cc3872c29ba2a57fe1b71b3e3c5649f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1692248770, + "narHash": "sha256-tZeFpETKQGbgnaSIO1AGWD27IyTcBm4D+A9d7ulQ4NM=", + "owner": "LnL7", + "repo": "nix-darwin", + "rev": "511177ffe8226c78c9cf6a92a7b5f2df3684956b", + "type": "github" + }, + "original": { + "owner": "LnL7", + "ref": "master", + "repo": "nix-darwin", + "type": "github" + } + }, "nixpkgs": { "locked": { - "lastModified": 1691990649, - "narHash": "sha256-gMbKOiX1HwClRP9lADaaV/lnZr93NEaOFe4ApDx/zd8=", + "lastModified": 1692232013, + "narHash": "sha256-a5hct9pN+RSxLclPBsWCg9zOCG9c0Uf1cq3XlntQpDQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e287913f7b1ef537c97aa301b67c34ea46b640f", + "rev": "edf586f399ddb6aef26edc2df3aa843e97a2ddc1", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-23.05-darwin", "repo": "nixpkgs", "type": "github" } @@ -50,6 +92,8 @@ }, "root": { "inputs": { + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" } @@ -60,11 +104,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1691915920, - "narHash": "sha256-4pitrahUZc1ftIw38CelScd+JYGUVZ4mQTMe3VAz44c=", + "lastModified": 1692127428, + "narHash": "sha256-+e9dD67mpGLBhhqdv7A7i1g/r2AT/PmqthWaYHyVZR4=", "owner": "Mic92", "repo": "sops-nix", - "rev": "32603de0dc988d60a7b80774dd7aed1083cd9629", + "rev": "f81e73cf9a4ef4b949b9225be3daa1e586c096da", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index c53a39d..18a2aff 100644 --- a/flake.nix +++ b/flake.nix @@ -1,8 +1,14 @@ { - inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - inputs.sops-nix.url = "github:Mic92/sops-nix"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin"; + sops-nix.url = "github:Mic92/sops-nix"; + nix-darwin.url = "github:LnL7/nix-darwin/master"; + nix-darwin.inputs.nixpkgs.follows = "nixpkgs"; + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; - outputs = { self, nixpkgs, sops-nix }@attrs: let + outputs = { self, nixpkgs, sops-nix, nix-darwin, home-manager }@attrs: let hydraGitea = (final: prev: { hydra_unstable = prev.hydra_unstable.overrideAttrs (old: { @@ -17,8 +23,12 @@ }); }); nvidiaContainer = import ./nvidiacontainer-overlay.nix nixpkgs; + + # Configuration for `nixpkgs` + nixpkgsConfig = { + config = { allowUnfree = true; }; + }; in { - nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = attrs; @@ -39,5 +49,16 @@ ./machines/universedesktop/configuration.nix ]; }; + darwinConfigurations."Universe-Air" = nix-darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = attrs; + modules = [ + ./machines/universeair/configuration.nix + home-manager.darwinModules.home-manager + { + nixpkgs = nixpkgsConfig; + } + ]; + }; }; } diff --git a/machines/universeair/configuration.nix b/machines/universeair/configuration.nix new file mode 100644 index 0000000..53efad0 --- /dev/null +++ b/machines/universeair/configuration.nix @@ -0,0 +1,73 @@ +{ config, pkgs, ... }: let +in + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + users.users.universelaptop = { + name = "universelaptop"; + home = "/Users/universelaptop"; + }; + home-manager.users.universelaptop = { pkgs, ... }: { + programs.direnv.enable = true; + programs.direnv.nix-direnv.enable = true; + programs.bash.enable = true; + programs.zsh = { + enable = true; + initExtra = '' +PATH=$HOME/flutter/bin:$PATH +DYLD_LIBRARY_PATH=MR/v99/runtime/maci64:MR/v99/sys/os/maci64:MR/v99/bin/maci64:$DYLD_LIBRARY_PATH +flakify() { + eval "$(direnv hook bash)" + if [ ! -e flake.nix ]; then + nix flake new -t github:nix-community/nix-direnv . + fi + $EDITOR flake.nix +} + ''; + shellAliases = { + ssh = "kitty +kitten ssh"; + sshu = "ssh universe@syzygial.cc -p 7000"; + tailscale = +"/Applications/Tailscale.app/Contents/MacOS/Tailscale"; + }; + }; + home.stateVersion = "22.05"; + }; + environment.variables = { + EDITOR = "emacs"; + }; + nixpkgs.config.allowUnfree = true; + + environment.systemPackages = (with pkgs; [ + emacs-macport + (aspellWithDicts (p: with p;[ + en + en-computers + en-science + ])) + pandoc + texlive.combined.scheme-full + wget + + kitty + + btop + + cbqn-replxx + + podman + qemu + ]); + # Or any other shell you're using. }; + # Auto upgrade nix package and the daemon service. + services.nix-daemon.enable = true; + nix.package = pkgs.nixUnstable; + nix.settings.auto-optimise-store = false; + # Create /etc/zshrc that loads the nix-darwin environment. + programs.bash.enable = true; # default shell on catalina + programs.zsh.enable = true; # default shell on catalina + + # Used for backwards compatibility, please read the changelog before changing. + # $ darwin-rebuild changelog + system.stateVersion = 4; + }