mirror of
https://github.com/srid/nixos-config.git
synced 2025-12-26 15:04:59 +08:00
parent
6a55b6a881
commit
e893599a90
3 changed files with 32 additions and 30 deletions
18
Makefile
18
Makefile
|
|
@ -1,21 +1,3 @@
|
|||
HOSTNAME := $(shell hostname -s)
|
||||
|
||||
all:
|
||||
if [[ "`uname`" == 'Darwin' ]]; then \
|
||||
echo macOS; \
|
||||
make macos-system; \
|
||||
else \
|
||||
echo NixOS; \
|
||||
make nixos-system; \
|
||||
fi
|
||||
|
||||
nixos-system:
|
||||
nixos-rebuild --use-remote-sudo switch -j auto
|
||||
|
||||
macos-system:
|
||||
sudo ls # cache sudo
|
||||
$$(nix build --extra-experimental-features "flakes nix-command" .#darwinConfigurations.$(HOSTNAME).system --no-link --json | nix --extra-experimental-features "flakes nix-command" run ${WITHEXP} nixpkgs#jq -- -r '.[].outputs.out')/sw/bin/darwin-rebuild switch --flake .
|
||||
|
||||
# Update the primary inputs
|
||||
#
|
||||
# Typically run as: `make update all` followed by a git commit.
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -3,9 +3,9 @@ This repository contains the Nix / NixOS configuration for all of my systems. St
|
|||
To build,
|
||||
|
||||
```sh
|
||||
# First, edit nixosConfigurations or darwinConfigurations in flake.nix to add
|
||||
# your system's hostname. And then change `userName` to your username.
|
||||
make
|
||||
# First, edit nixosConfigurations in flake.nix to add your system's hostname.
|
||||
# And then change `userName` to your username.
|
||||
nix run
|
||||
```
|
||||
|
||||
## Install notes
|
||||
|
|
@ -18,14 +18,14 @@ make
|
|||
- Windows (via WSL): https://github.com/nix-community/NixOS-WSL
|
||||
- Clone this repo at `/etc/nixos`
|
||||
- Edit `flake.nix` and add your Linux's hostname in the `nixosConfigurations` set, as well as update `userName`.
|
||||
- Run `make`. That's it. Re-open your shell.
|
||||
- Run `nix run`. That's it. Re-open your shell.
|
||||
- macOS:
|
||||
- Install Nix normally (multi-user)
|
||||
- Install [nix-darwin](https://github.com/LnL7/nix-darwin)
|
||||
- This will create a `~/.nixpkgs/darwin-configuration.nix`, but we do not need that.
|
||||
- Clone this repo anywhere
|
||||
- Edit `flake.nix` and add your Mac's [hostname](https://support.apple.com/en-ca/guide/mac-help/mchlp2322/mac) in the `darwinConfigurations` set, as well update `userName`.
|
||||
- Run `make`.[^cleanup] That's it. Re-open your shell.
|
||||
- Run `nix run`.[^cleanup] That's it. Re-open your shell.
|
||||
|
||||
[^cleanup]: You might have to `rm -rf /etc/nix/nix.conf`, so our flake.nix can do its thing.
|
||||
|
||||
|
|
|
|||
34
flake.nix
34
flake.nix
|
|
@ -163,14 +163,8 @@
|
|||
};
|
||||
in
|
||||
{
|
||||
# These are indexed, by convention, using hostnames.
|
||||
# For example, if `sky.local` is the hostname of your Mac, then use
|
||||
# `sky` here.
|
||||
air = defaultMacosSystem;
|
||||
sky = defaultMacosSystem;
|
||||
default = defaultMacosSystem;
|
||||
};
|
||||
|
||||
|
||||
} //
|
||||
inputs.flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system:
|
||||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
|
|
@ -184,6 +178,32 @@
|
|||
];
|
||||
};
|
||||
formatter = pkgs.nixpkgs-fmt;
|
||||
apps.default =
|
||||
let
|
||||
bashCmdApp = name: cmd: {
|
||||
type = "app";
|
||||
program =
|
||||
let
|
||||
pkgs = inputs.nixpkgs.legacyPackages.aarch64-darwin;
|
||||
in
|
||||
(pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
text = ''
|
||||
set -x
|
||||
${cmd}
|
||||
'';
|
||||
}) + "/bin/${name}";
|
||||
};
|
||||
in
|
||||
if system == "aarch64-darwin" then
|
||||
bashCmdApp "darwin" ''
|
||||
${self.darwinConfigurations.default.system}/sw/bin/darwin-rebuild \
|
||||
switch --flake ${self}#default
|
||||
''
|
||||
else
|
||||
bashCmdApp "linux" ''
|
||||
nixos-rebuild --use-remote-sudo switch -j auto
|
||||
'';
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue