mirror of
https://github.com/LnL7/nix-darwin.git
synced 2025-03-05 08:17:01 +00:00
Merge pull request #688 from Enzime/add/template
flake: add template with basic flake config
This commit is contained in:
commit
1759eb2699
4 changed files with 67 additions and 45 deletions
30
.github/workflows/test.yml
vendored
30
.github/workflows/test.yml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix corresponding to latest stable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install
|
||||
extra_nix_config: |
|
||||
|
@ -28,7 +28,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix from current unstable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }}
|
||||
extra_nix_config: |
|
||||
|
@ -43,7 +43,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix corresponding to latest stable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install
|
||||
nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }}
|
||||
|
@ -80,7 +80,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix from current unstable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
extra_nix_config: |
|
||||
|
@ -116,7 +116,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix version corresponding to latest stable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
install_url: https://github.com/nix-community/nix-unstable-installer/releases/download/nix-2.10.0pre20220822_7c3ab57/install
|
||||
nix_path: nixpkgs=channel:${{ env.CURRENT_STABLE_CHANNEL }}
|
||||
|
@ -133,14 +133,14 @@ jobs:
|
|||
nix-shell -A installer.check
|
||||
- name: Build simple flake configuration
|
||||
run: |
|
||||
nix build ./modules/examples#darwinConfigurations.simple.system --override-input darwin .
|
||||
nix build ./modules/examples/flake#darwinConfigurations.simple.system --override-input darwin .
|
||||
- name: Activate derivation of simple flake build
|
||||
run: |
|
||||
./result/sw/bin/darwin-rebuild switch --flake ./modules/examples#simple --override-input darwin .
|
||||
./result/sw/bin/darwin-rebuild switch --flake ./modules/examples/flake#simple --override-input darwin .
|
||||
- name: Rebuild and activate simple flake, but this time using nix-darwins flake interface
|
||||
run: |
|
||||
. /etc/static/bashrc
|
||||
darwin-rebuild build --flake ./modules/examples#simple --override-input darwin .
|
||||
darwin-rebuild build --flake ./modules/examples/flake#simple --override-input darwin .
|
||||
- name: Test git submodules
|
||||
run: |
|
||||
. /etc/static/bashrc
|
||||
|
@ -155,10 +155,11 @@ jobs:
|
|||
popd
|
||||
|
||||
cp -a ./modules/examples/. /tmp/test-nix-darwin-submodules
|
||||
cp -a ./modules/examples/flake/flake.nix /tmp/test-nix-darwin-submodules
|
||||
|
||||
pushd /tmp/test-nix-darwin-submodules
|
||||
/usr/bin/sed -i.bak \
|
||||
'\#modules = \[#s#darwin.darwinModules.simple#./simple.nix#' \
|
||||
'\#modules = \[#s#configuration#configuration ./simple.nix#' \
|
||||
./flake.nix
|
||||
/usr/bin/sed -i.bak \
|
||||
's#pkgs.vim#pkgs."${import ./submodule-test/hello.nix}"#' \
|
||||
|
@ -198,7 +199,7 @@ jobs:
|
|||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install nix from current unstable channel
|
||||
uses: cachix/install-nix-action@v20
|
||||
uses: cachix/install-nix-action@v22
|
||||
with:
|
||||
nix_path: nixpkgs=channel:nixpkgs-unstable
|
||||
extra_nix_config: |
|
||||
|
@ -214,14 +215,14 @@ jobs:
|
|||
nix-shell -A installer.check
|
||||
- name: Build simple flake configuration
|
||||
run: |
|
||||
nix build ./modules/examples#darwinConfigurations.simple.system --override-input darwin .
|
||||
nix build ./modules/examples/flake#darwinConfigurations.simple.system --override-input darwin .
|
||||
- name: Activate derivation of simple flake build
|
||||
run: |
|
||||
./result/sw/bin/darwin-rebuild switch --flake ./modules/examples#simple --override-input darwin .
|
||||
./result/sw/bin/darwin-rebuild switch --flake ./modules/examples/flake#simple --override-input darwin .
|
||||
- name: Rebuild and activate simple flake, but this time using nix-darwins flake interface
|
||||
run: |
|
||||
. /etc/static/bashrc
|
||||
darwin-rebuild build --flake ./modules/examples#simple --override-input darwin .
|
||||
darwin-rebuild build --flake ./modules/examples/flake#simple --override-input darwin .
|
||||
- name: Test git submodules
|
||||
run: |
|
||||
. /etc/static/bashrc
|
||||
|
@ -236,10 +237,11 @@ jobs:
|
|||
popd
|
||||
|
||||
cp -a ./modules/examples/. /tmp/test-nix-darwin-submodules
|
||||
cp -a ./modules/examples/flake/flake.nix /tmp/test-nix-darwin-submodules
|
||||
|
||||
pushd /tmp/test-nix-darwin-submodules
|
||||
/usr/bin/sed -i.bak \
|
||||
'\#modules = \[#s#darwin.darwinModules.simple#./simple.nix#' \
|
||||
'\#modules = \[#s#configuration#configuration ./simple.nix#' \
|
||||
./flake.nix
|
||||
/usr/bin/sed -i.bak \
|
||||
's#pkgs.vim#pkgs."${import ./submodule-test/hello.nix}"#' \
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
darwinModules.ofborg = ./modules/examples/ofborg.nix;
|
||||
darwinModules.simple = ./modules/examples/simple.nix;
|
||||
|
||||
templates.default = {
|
||||
path = ./modules/examples/flake;
|
||||
description = "nix flake init -t nix-darwin";
|
||||
};
|
||||
|
||||
checks.x86_64-darwin.simple = (self.lib.darwinSystem {
|
||||
system = "x86_64-darwin";
|
||||
modules = [ self.darwinModules.simple ];
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
{
|
||||
description = "Example darwin system flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
darwin.url = "github:lnl7/nix-darwin";
|
||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, darwin, nixpkgs }:
|
||||
let
|
||||
configuration = { pkgs, ... }: {
|
||||
nix.package = pkgs.nixVersions.stable;
|
||||
|
||||
# FIXME: for github actions, this shouldn't be in the example.
|
||||
services.nix-daemon.enable = true;
|
||||
};
|
||||
in
|
||||
{
|
||||
# Build darwin flake using:
|
||||
# $ darwin-rebuild build --flake ./modules/examples#simple \
|
||||
# --override-input darwin .
|
||||
darwinConfigurations."simple" = darwin.lib.darwinSystem {
|
||||
modules = [ configuration darwin.darwinModules.simple ];
|
||||
system = "x86_64-darwin";
|
||||
};
|
||||
|
||||
# Expose the package set, including overlays, for convenience.
|
||||
darwinPackages = self.darwinConfigurations."simple".pkgs;
|
||||
};
|
||||
}
|
46
modules/examples/flake/flake.nix
Normal file
46
modules/examples/flake/flake.nix
Normal file
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
description = "Example darwin system flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
darwin.url = "github:lnl7/nix-darwin";
|
||||
darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, darwin, nixpkgs }:
|
||||
let
|
||||
configuration = { pkgs, ... }: {
|
||||
# List packages installed in system profile. To search by name, run:
|
||||
# $ nix-env -qaP | grep wget
|
||||
environment.systemPackages =
|
||||
[ pkgs.vim
|
||||
];
|
||||
|
||||
# Auto upgrade nix package and the daemon service.
|
||||
services.nix-daemon.enable = true;
|
||||
# nix.package = pkgs.nix;
|
||||
|
||||
# Necessary for using flakes on this system.
|
||||
nix.settings.experimental-features = "nix-command flakes";
|
||||
|
||||
# Create /etc/zshrc 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;
|
||||
};
|
||||
in
|
||||
{
|
||||
# Build darwin flake using:
|
||||
# $ darwin-rebuild build --flake .#simple
|
||||
darwinConfigurations."simple" = darwin.lib.darwinSystem {
|
||||
modules = [ configuration ];
|
||||
system = "x86_64-darwin";
|
||||
};
|
||||
|
||||
# Expose the package set, including overlays, for convenience.
|
||||
darwinPackages = self.darwinConfigurations."simple".pkgs;
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue