From 483b9514d91eaae142747dfb044629588b201694 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Sat, 18 Dec 2021 16:35:11 -0500 Subject: [PATCH] add m1 mac config --- features/nix-direnv.nix | 18 ++++++++++++++++ flake.nix | 17 +++++++++++++-- hosts/darwin.nix | 48 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 features/nix-direnv.nix create mode 100644 hosts/darwin.nix diff --git a/features/nix-direnv.nix b/features/nix-direnv.nix new file mode 100644 index 0000000..1581a47 --- /dev/null +++ b/features/nix-direnv.nix @@ -0,0 +1,18 @@ +{ config, pkgs, rosettaPkgs, ... }: + +{ + # https://github.com/nix-community/nix-direnv + environment.systemPackages = with pkgs; [ direnv nix-direnv ]; + # nix options for derivations to persist garbage collection + nix.extraOptions = '' + keep-outputs = true + keep-derivations = true + ''; + environment.pathsToLink = [ + "/share/nix-direnv" + ]; + nixpkgs.overlays = [ + (self: super: { nix-direnv = super.nix-direnv.override { enableFlakes = true; }; }) + ]; + +} diff --git a/flake.nix b/flake.nix index f13f1b1..9cca003 100644 --- a/flake.nix +++ b/flake.nix @@ -6,7 +6,9 @@ # https://status.nixos.org/ # # This ensures that we always use the official nix cache. - nixpkgs.url = "github:nixos/nixpkgs/a2e281f5770247855b85d70c43454ba5bff34613"; + nixpkgs.url = "github:nixos/nixpkgs/03ec468b14067729a285c2c7cfa7b9434a04816c"; + darwin.url = "github:lnl7/nix-darwin/master"; + darwin.inputs.nixpkgs.follows = "nixpkgs"; nixos-hardware.url = github:NixOS/nixos-hardware/master; home-manager.url = "github:nix-community/home-manager"; @@ -22,7 +24,7 @@ hercules-ci-agent.url = "github:hercules-ci/hercules-ci-agent/stable"; }; - outputs = inputs@{ self, home-manager, nixpkgs, ... }: + outputs = inputs@{ self, home-manager, nixpkgs, darwin, ... }: let system = "x86_64-linux"; # Add nixpkgs overlays and config here. They apply to system and home-manager builds. @@ -96,6 +98,17 @@ ]; }; + darwinConfigurations."air" = darwin.lib.darwinSystem { + system = "aarch64-darwin"; + specialArgs = { + rosettaPkgs = import nixpkgs { system = "x86_64-darwin"; }; + }; + modules = [ + ./hosts/darwin.nix + ./features/nix-direnv.nix + ]; + }; + # non-NixOS systems homeConfigurations = let diff --git a/hosts/darwin.nix b/hosts/darwin.nix new file mode 100644 index 0000000..347c86c --- /dev/null +++ b/hosts/darwin.nix @@ -0,0 +1,48 @@ +{ config, pkgs, rosettaPkgs, ... }: + +{ + # List packages installed in system profile. To search by name, run: + # $ nix-env -qaP | grep wget + environment.systemPackages = with pkgs; [ + wget + aria2 + ripgrep + sd + tig + tmux + pass + + # We must install Agda globally so that Doom-Emacs' agda config can + # recognize it. It doesn't matter that our projects use Nix/direnv. + # + # Emacs configuration system assumes global state, and is thus shit. We just work with it. + # https://github.com/hlissner/doom-emacs/blob/f458f9776049fd7e9523318582feed682e7d575c/modules/lang/agda/config.el#L3-L8 + (rosettaPkgs.agda.withPackages (p: [ p.standard-library ])) + rosettaPkgs.idris2 + #rosettaPkgs.coq + # (rosettaPkgs.haskellPackages.callHackage "agda-language-server" "0.2.1" { }) + ]; + + nix.extraOptions = '' + extra-platforms = aarch64-darwin x86_64-darwin + experimental-features = nix-command flakes + ''; + + nixpkgs.config.allowBroken = true; + + # 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.nix; + + # 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; +}