mirror of
https://github.com/davegallant/nix-config
synced 2025-08-05 23:03:40 +00:00
Switch to a Makefile
This commit is contained in:
21
Makefile
Normal file
21
Makefile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
SHELL := bash
|
||||||
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
|
.DELETE_ON_ERROR:
|
||||||
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
MAKEFLAGS += --no-builtin-rules
|
||||||
|
|
||||||
|
HOSTAME ?= $(shell hostname)
|
||||||
|
UNAME_S := $(shell uname -s)
|
||||||
|
|
||||||
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
SWITCH_CMD := sudo nixos-rebuild -I nixos-config="machines/$(HOSTNAME)/configuration.nix" switch --flake '.\#'
|
||||||
|
endif
|
||||||
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
SWITCH_CMD := exec darwin-rebuild switch --flake .
|
||||||
|
endif
|
||||||
|
|
||||||
|
switch:
|
||||||
|
$(SWITCH_CMD)
|
||||||
|
|
||||||
|
update:
|
||||||
|
nix flake update
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[](https://builtwithnix.org)
|
[](https://builtwithnix.org)
|
||||||
|
|
||||||
This repo stores nix to manage my machines running both [NixOS](https://nixos.org/) and macOS. The initial structure was inspired by [samuelgrf/nixos-config](https://gitlab.com/samuelgrf/nixos-config/-/tree/master/).
|
This repo stores nix to manage my machines running both [NixOS](https://nixos.org/) and macOS.
|
||||||
|
|
||||||
The configuration is very specific to my own machines and setup, but it may be a useful reference for anyone else learning or experimenting with nix, whether it be on a personal machine or a server.
|
The configuration is very specific to my own machines and setup, but it may be a useful reference for anyone else learning or experimenting with nix, whether it be on a personal machine or a server.
|
||||||
|
|
||||||
@@ -14,16 +14,15 @@ The configuration is very specific to my own machines and setup, but it may be a
|
|||||||
To run a rebuild:
|
To run a rebuild:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./rebuild.sh switch
|
make switch
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Update
|
## Update
|
||||||
|
|
||||||
To update nixpkgs defined in [flake.nix](./flake.nix), run:
|
To update nixpkgs defined in [flake.nix](./flake.nix), run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
nix flake update
|
make update
|
||||||
```
|
```
|
||||||
|
|
||||||
If there are updates, they should be reflected in [flake.lock](./flake.lock).
|
If there are updates, they should be reflected in [flake.lock](./flake.lock).
|
||||||
|
18
flake.lock
generated
18
flake.lock
generated
@@ -58,11 +58,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1635017514,
|
"lastModified": 1635285717,
|
||||||
"narHash": "sha256-tdV/y8nJZqKDoqFVE8ORB0drdGdSze2xeWfhWz9M3oo=",
|
"narHash": "sha256-CGsOBSkdjIHmKEbUkik1JKQhiKCJ64Hj7dROx7yEDCo=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "406eeec0b98903561767ce7aca311034d298d53e",
|
"rev": "46a69810cb95d2e7286089830dc535d6719eaa6f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -81,11 +81,11 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "contrib",
|
"dir": "contrib",
|
||||||
"lastModified": 1635040504,
|
"lastModified": 1635085216,
|
||||||
"narHash": "sha256-EtwuXPxOnITZSyQKO4OiB4mc6GFFPYhyA+dtJIX87DQ=",
|
"narHash": "sha256-gy1TjtpL8Sjaa7UnwsdcgmvsxA57D16kXMbDqSfHgGI=",
|
||||||
"owner": "neovim",
|
"owner": "neovim",
|
||||||
"repo": "neovim",
|
"repo": "neovim",
|
||||||
"rev": "6acebb8b56e21247423a5692e9ca30dff05abb63",
|
"rev": "09e96fe6096f07365eb65b51bb7f2fd0f1b043b0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -102,11 +102,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1635063163,
|
"lastModified": 1635149654,
|
||||||
"narHash": "sha256-RZ2xoYcAnk67UTy0isQ5+UEwQ5uBffrzU5wUKGC3saw=",
|
"narHash": "sha256-JxqJEtG744ZMrLiGxZgoGh2eWergDVm9VN5xSgPyo8E=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "neovim-nightly-overlay",
|
"repo": "neovim-nightly-overlay",
|
||||||
"rev": "5ff5c9f2d167d348bd959fa4eddf37e84493a261",
|
"rev": "c4e9149ff03c9d77bc9023d1bd658bfbb3035bc0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
20
rebuild.sh
20
rebuild.sh
@@ -1,20 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
cd "$(dirname "$0")" || exit
|
|
||||||
|
|
||||||
uname="$(uname -s)"
|
|
||||||
case "${uname}" in
|
|
||||||
Linux*) machine=linux ;;
|
|
||||||
Darwin*) machine=mac ;;
|
|
||||||
*) machine="unknown" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [[ "$machine" == "linux" ]]; then
|
|
||||||
sudo nixos-rebuild -I nixos-config="machines/$(hostname)/configuration.nix" "$@" --flake '.#'
|
|
||||||
elif [[ "$machine" == "mac" ]]; then
|
|
||||||
exec darwin-rebuild "$@" --flake .
|
|
||||||
else
|
|
||||||
echo 'Unsupported OS.'
|
|
||||||
echo 'Exiting...'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
Reference in New Issue
Block a user