mirror of
https://github.com/srid/nixos-config.git
synced 2026-01-18 13:27:55 +08:00
Merge pull request #11 from srid/darwin
This commit is contained in:
commit
bf2e47c550
6 changed files with 129 additions and 13 deletions
11
Makefile
11
Makefile
|
|
@ -1,15 +1,16 @@
|
|||
OS := $(shell uname)
|
||||
|
||||
|
||||
all:
|
||||
@if [ -d "/etc/nixos" ]; then \
|
||||
make nixos;\
|
||||
else \
|
||||
make h;\
|
||||
fi
|
||||
echo "fuck you shell scripting"
|
||||
|
||||
nixos:
|
||||
sudo nixos-rebuild switch -j auto
|
||||
# systemctl restart --user emanote
|
||||
|
||||
macos:
|
||||
$$(nix build --extra-experimental-features "flakes nix-command" .#darwinConfigurations.air.system --no-link --json | jq -r '.[].outputs.out')/sw/bin/darwin-rebuild switch --flake .
|
||||
|
||||
# Not sure why this doesn't reliably work
|
||||
h0:
|
||||
nix build ".#homeConfigurations."`hostname`".activationPackage"
|
||||
|
|
|
|||
18
README.md
18
README.md
|
|
@ -1,12 +1,26 @@
|
|||
This repository contains the Nix / NixOS configuration for all of my systems. Start from `flakes.nix` (see [Flakes](https://nixos.wiki/wiki/Flakes)) if you are looking for NixOS configuration. Start from `home.nix` if you are looking for non-NixOS Nix configuration (eg: on macOS).
|
||||
|
||||
- `home.nix`: Only install things that are needed in all platforms (VMs, VPS, WSL2, etc.)
|
||||
- TODO: macOS M1 => https://github.com/srid/m1-mac-nix
|
||||
- `flake.nix`: Install things I need natively on NixOS desktop & laptop computers
|
||||
|
||||
VSCode note: <kbd>Ctrl+Shift+B</kbd> will run effectuate the new configuration (by running `make`).
|
||||
|
||||
## Non-NixOS
|
||||
|
||||
## Platforms
|
||||
|
||||
### NixOS
|
||||
|
||||
```
|
||||
make nixos
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
```
|
||||
make darwin
|
||||
```
|
||||
|
||||
### Other Linux distro (home-manager)
|
||||
|
||||
TODO: This section needs an update.
|
||||
|
||||
|
|
|
|||
18
features/nix-direnv.nix
Normal file
18
features/nix-direnv.nix
Normal file
|
|
@ -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; }; })
|
||||
];
|
||||
|
||||
}
|
||||
30
flake.lock
generated
30
flake.lock
generated
|
|
@ -17,6 +17,27 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"darwin": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"doom-emacs": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
|
@ -740,17 +761,17 @@
|
|||
},
|
||||
"nixpkgs_8": {
|
||||
"locked": {
|
||||
"lastModified": 1639525045,
|
||||
"narHash": "sha256-z4GXFNzO+5V4CAUm2DDMAryLOWUKEbQif2ifvv1Ypg4=",
|
||||
"lastModified": 1639699734,
|
||||
"narHash": "sha256-tlX6WebGmiHb2Hmniff+ltYp+7dRfdsBxw9YczLsP60=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a2e281f5770247855b85d70c43454ba5bff34613",
|
||||
"rev": "03ec468b14067729a285c2c7cfa7b9434a04816c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "a2e281f5770247855b85d70c43454ba5bff34613",
|
||||
"rev": "03ec468b14067729a285c2c7cfa7b9434a04816c",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
|
|
@ -884,6 +905,7 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"darwin": "darwin",
|
||||
"emacs-overlay": "emacs-overlay",
|
||||
"emanote": "emanote",
|
||||
"hercules-ci-agent": "hercules-ci-agent",
|
||||
|
|
|
|||
17
flake.nix
17
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
|
||||
|
|
|
|||
48
hosts/darwin.nix
Normal file
48
hosts/darwin.nix
Normal file
|
|
@ -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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue