mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3be6dfbaca |
No files matched your search
@@ -1,14 +0,0 @@
|
||||
name: Auto Merge Dependency Updates
|
||||
on:
|
||||
- pull_request_target
|
||||
jobs:
|
||||
auto-merge-dependency-updates:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
concurrency:
|
||||
group: "auto-merge:${{ github.head_ref }}"
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- uses: Mic92/auto-merge@main
|
||||
@@ -1,30 +1,21 @@
|
||||
name: "Update flakes"
|
||||
name: update-flake-lock
|
||||
on:
|
||||
workflow_dispatch:
|
||||
workflow_dispatch: # allows manual triggering
|
||||
schedule:
|
||||
- cron: "0 0 * * 1,4"
|
||||
|
||||
- cron: '0 0 * * 1,4' # Run twice a week
|
||||
permissions:
|
||||
pull-requests: write
|
||||
contents: write
|
||||
jobs:
|
||||
createPullRequest:
|
||||
lockfile:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v6
|
||||
- name: Install Nix
|
||||
uses: cachix/install-nix-action@v31
|
||||
- name: Update flake.lock
|
||||
uses: DeterminateSystems/update-flake-lock@v28
|
||||
with:
|
||||
extra_nix_config: |
|
||||
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||
- uses: actions/create-github-app-token@v3
|
||||
id: app-token
|
||||
with:
|
||||
app-id: ${{ vars.APP_ID }}
|
||||
private-key: ${{ secrets.APP_PRIVATE_KEY }}
|
||||
- name: Update flakes
|
||||
run: nix flake update
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v8
|
||||
with:
|
||||
title: "flake: update inputs"
|
||||
token: ${{ steps.app-token.outputs.token }}
|
||||
labels: |
|
||||
auto-merge
|
||||
pr-labels: |
|
||||
merge-queue
|
||||
@@ -0,0 +1,12 @@
|
||||
queue_rules:
|
||||
- name: default
|
||||
merge_conditions:
|
||||
- check-success=buildbot/nix-build
|
||||
merge_method: rebase
|
||||
pull_request_rules:
|
||||
- name: merge using the merge queue
|
||||
conditions:
|
||||
- base=master
|
||||
- label=merge-queue
|
||||
actions:
|
||||
queue: {}
|
||||
@@ -8,7 +8,7 @@ Follow the steps below to generate disk images:
|
||||
1. **Create a NixOS configuration that includes the disko and the disk
|
||||
configuration of your choice**
|
||||
|
||||
In this example we create a flake containing a nixos configuration for
|
||||
In the this example we create a flake containing a nixos configuration for
|
||||
`myhost`.
|
||||
|
||||
```nix
|
||||
@@ -79,7 +79,7 @@ In this example we create a flake containing a nixos configuration for
|
||||
They will have the same permissions but will be owned by root:root
|
||||
* --build-memory <amt>
|
||||
specify the amount of memory in MiB that gets allocated to the build VM
|
||||
This can be useful if you want to build images with a more involved NixOS config
|
||||
This can be useful if you want to build images with a more involed NixOS config
|
||||
The default is 1024 MiB
|
||||
```
|
||||
|
||||
@@ -107,7 +107,7 @@ In this example we create a flake containing a nixos configuration for
|
||||
disko.devices.disk.<drive>.imageName = "nixos-x86_64-linux-generic-btrfs"; # Set your preferred name
|
||||
```
|
||||
|
||||
The image script will produce `nixos-x86_64-linux-generic-btrfs.raw` instead of `<drive>.raw`.
|
||||
The image scirpt will produce `nixos-x86_64-linux-generic-btrfs.raw` instead of `<drive>.raw`.
|
||||
|
||||
- For virtual drive use, define the image size in your Disko configuration:
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Running Interactive VMs with `disko`
|
||||
|
||||
disko now exports its own flavor of interactive VMs (similar to
|
||||
disko now exports its own flavor of interactive VMs (similiar to
|
||||
config.system.build.vm). Simply import the disko module and build the vm runner
|
||||
with:
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ for example like this:
|
||||
|
||||
## Remediation
|
||||
|
||||
The new GPT layout (`type = "gpt"`) uses partlabels to realize the partition
|
||||
The new GPT layout (`type = "gpt"`) uses partlabels to realize the partiton
|
||||
numbering. For this reason you have to manually set up partition labels, if you
|
||||
want to resolve this issue.
|
||||
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# This example with the legacy table should not be used. We recommend using the
|
||||
# gpt type instead. More information about this warning may be found in the
|
||||
# documentation.
|
||||
#
|
||||
# https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# This example with the legacy table should not be used. We recommend using the
|
||||
# gpt type instead. More information about this warning may be found in the
|
||||
# documentation.
|
||||
#
|
||||
# https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md
|
||||
{
|
||||
disko.devices = {
|
||||
disk = {
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# This example with the legacy table should not be used. We recommend using the
|
||||
# gpt type instead. More information about this warning may be found in the
|
||||
# documentation.
|
||||
#
|
||||
# https://github.com/nix-community/disko/blob/master/docs/table-to-gpt.md
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
|
||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1772771118,
|
||||
"narHash": "sha256-xWzaTvmmACR/SRWtABgI/Z97lcqwJAeoSd5QW1KdK1s=",
|
||||
"lastModified": 1763618868,
|
||||
"narHash": "sha256-v5afmLjn/uyD9EQuPBn7nZuaZVV9r+JerayK/4wvdWA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e38213b91d3786389a446dfce4ff5a8aaf6012f2",
|
||||
"rev": "a8d610af3f1a5fb71e23e08434d8d61a466fc942",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
text = ''treefmt "$@"'';
|
||||
runtimeInputs = [
|
||||
pkgs.deadnix
|
||||
pkgs.nixfmt
|
||||
pkgs.nixfmt-rfc-style
|
||||
pkgs.shellcheck
|
||||
pkgs.treefmt
|
||||
];
|
||||
|
||||
+7
-65
@@ -6,13 +6,8 @@
|
||||
qemu-common ? import <nixpkgs/nixos/lib/qemu-common.nix>,
|
||||
}:
|
||||
let
|
||||
# qemu-common is a function that takes { lib, stdenv } and returns QEMU utilities
|
||||
qemu-common-lib =
|
||||
pkgs:
|
||||
qemu-common {
|
||||
inherit lib;
|
||||
inherit (pkgs) stdenv;
|
||||
};
|
||||
# qemu-common is a function that takes { lib, pkgs } and returns QEMU utilities
|
||||
qemu-common-lib = pkgs: qemu-common { inherit lib pkgs; };
|
||||
|
||||
outputs = import ../default.nix { inherit lib diskoLib; };
|
||||
diskoLib = {
|
||||
@@ -200,6 +195,7 @@ let
|
||||
_path: lhs: rhs:
|
||||
!(isAttrs lhs && isAttrs rhs)
|
||||
) lhs rhs;
|
||||
|
||||
in
|
||||
recursiveMerge left right;
|
||||
|
||||
@@ -390,44 +386,6 @@ let
|
||||
*/
|
||||
maybeStr = x: lib.optionalString (x != null) x;
|
||||
|
||||
/*
|
||||
Check whenever `b` depends on `a` as a fileSystem
|
||||
|
||||
Note: copied from nixpkgs/nixos/utils.nix @ 47718fe8858fa4642cd6a4f0b5a1173bad9ce8df
|
||||
because the file that exports it is not meant to be used standalone.
|
||||
*/
|
||||
fsBefore =
|
||||
a: b:
|
||||
with lib;
|
||||
let
|
||||
# normalisePath adds a slash at the end of the path if it didn't already
|
||||
# have one.
|
||||
#
|
||||
# The reason slashes are added at the end of each path is to prevent `b`
|
||||
# from accidentally depending on `a` in cases like
|
||||
# a = { mountPoint = "/aaa"; ... }
|
||||
# b = { device = "/aaaa"; ... }
|
||||
# Here a.mountPoint *is* a prefix of b.device even though a.mountPoint is
|
||||
# *not* a parent of b.device. If we add a slash at the end of each string,
|
||||
# though, this is not a problem: "/aaa/" is not a prefix of "/aaaa/".
|
||||
normalisePath = path: "${path}${optionalString (!(hasSuffix "/" path)) "/"}";
|
||||
normalise =
|
||||
mount:
|
||||
mount
|
||||
// {
|
||||
device = normalisePath (toString mount.device);
|
||||
mountPoint = normalisePath mount.mountPoint;
|
||||
depends = map normalisePath mount.depends;
|
||||
};
|
||||
|
||||
a' = normalise a;
|
||||
b' = normalise b;
|
||||
|
||||
in
|
||||
hasPrefix a'.mountPoint b'.device
|
||||
|| hasPrefix a'.mountPoint b'.mountPoint
|
||||
|| any (hasPrefix a'.mountPoint) b'.depends;
|
||||
|
||||
/*
|
||||
Takes a Submodules config and options argument and returns a serializable
|
||||
subset of config variables as a shell script snippet.
|
||||
@@ -940,7 +898,7 @@ let
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
The script to unmount (& destroy) all devices defined by disko.devices
|
||||
Does not ask for confirmation! Deprecated in favor of _destroy
|
||||
Does not ask for confirmation! Depracated in favor of _destroy
|
||||
'';
|
||||
default = ''
|
||||
umount -Rv "${rootMountPoint}" || :
|
||||
@@ -1027,25 +985,9 @@ let
|
||||
default =
|
||||
with lib;
|
||||
let
|
||||
mountOrder = pipe cfg.config._config.fileSystems.contents [
|
||||
(foldl' recursiveUpdate { })
|
||||
(mapAttrsToList (
|
||||
mountPoint: value:
|
||||
value
|
||||
// {
|
||||
mountPoint = value.mountPoint or mountPoint;
|
||||
depends = [ ];
|
||||
}
|
||||
))
|
||||
(toposort diskoLib.fsBefore)
|
||||
(getAttr "result")
|
||||
(map (getAttr "mountPoint"))
|
||||
];
|
||||
|
||||
fsMounts = diskoLib.deepMergeMap (dev: dev._mount.fs or { }) (
|
||||
flatten (map attrValues (attrValues devices))
|
||||
);
|
||||
|
||||
sortedDeviceList = diskoLib.sortDevicesByDependencies (cfg.config._meta.deviceDependencies or { }
|
||||
) devices;
|
||||
in
|
||||
@@ -1054,8 +996,8 @@ let
|
||||
# first create the necessary devices
|
||||
${concatMapStrings (dev: (attrByPath (dev ++ [ "_mount" ]) { } devices).dev or "") sortedDeviceList}
|
||||
|
||||
# and then mount the filesystems in dependency order
|
||||
${concatStrings (attrVals mountOrder fsMounts)}
|
||||
# and then mount the filesystems in alphabetical order
|
||||
${concatStrings (attrValues fsMounts)}
|
||||
'';
|
||||
};
|
||||
_unmount = lib.mkOption {
|
||||
@@ -1075,7 +1017,7 @@ let
|
||||
in
|
||||
''
|
||||
set -efux
|
||||
# first unmount the filesystems in reverse dependency order
|
||||
# first unmount the filesystems in reverse alphabetical order
|
||||
${concatStrings (lib.reverseList (attrValues fsMounts))}
|
||||
|
||||
# Than close the devices
|
||||
|
||||
@@ -144,7 +144,7 @@ let
|
||||
# (nix refuses symlinks in store path hierarchy)
|
||||
rootMountPoint=$(realpath ${lib.escapeShellArg systemToInstall.config.disko.rootMountPoint})
|
||||
# populate nix db, so nixos-install doesn't complain
|
||||
export NIX_STATE_DIR="$rootMountPoint"/nix/var/nix
|
||||
export NIX_STATE_DIR=$rootMountPoint/nix/var/nix
|
||||
nix-store --load-db < "${closureInfo}/registration"
|
||||
|
||||
# We copy files with cp because `nix copy` has a large memory leak.
|
||||
@@ -209,7 +209,7 @@ in
|
||||
They will have the same permissions but will be owned by root:root
|
||||
* --build-memory <amt>
|
||||
specify the amount of memory in MiB that gets allocated to the build VM
|
||||
This can be useful if you want to build images with a more involved NixOS config
|
||||
This can be useful if you want to build images with a more involed NixOS config
|
||||
The default is disko.memSize which defaults to ${builtins.toString options.disko.memSize.default} MiB
|
||||
USAGE
|
||||
}
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ let
|
||||
boot.swraid.mdadmConf = "PROGRAM ${pkgs.coreutils}/bin/true";
|
||||
|
||||
# grub will install to these devices, we need to force those or we are offset by 1
|
||||
# we use mkOverride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
||||
# we use mkOveride 70, so that users can override this with mkForce in case they are testing grub mirrored boots
|
||||
boot.loader.grub.devices = lib.mkOverride 70 testConfigInstall.boot.loader.grub.devices;
|
||||
|
||||
assertions = [
|
||||
|
||||
+1
-1
@@ -305,7 +305,7 @@ in
|
||||
--align-end ${
|
||||
lib.optionalString (
|
||||
partition.alignment != 0
|
||||
) "--set-alignment=${builtins.toString partition.alignment}"
|
||||
) ''--set-alignment=${builtins.toString partition.alignment}''
|
||||
} \
|
||||
--new=${toString partition._index}:${partition.start}:${partition.end} \
|
||||
'';
|
||||
|
||||
+9
-14
@@ -57,20 +57,15 @@ in
|
||||
};
|
||||
_mount = diskoLib.mkMountOption {
|
||||
inherit config options;
|
||||
default =
|
||||
let
|
||||
isBindMount = builtins.elem "bind" config.mountOptions;
|
||||
device = if isBindMount then "${rootMountPoint}${config.device}" else config.device;
|
||||
in
|
||||
lib.optionalAttrs (config.mountpoint != null) {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount -t ${config.fsType} "${device}" "${rootMountPoint}${config.mountpoint}" \
|
||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
'';
|
||||
};
|
||||
default = lib.optionalAttrs (config.mountpoint != null) {
|
||||
fs.${config.mountpoint} = ''
|
||||
if ! findmnt ${config.fsType} "${rootMountPoint}${config.mountpoint}" > /dev/null 2>&1; then
|
||||
mount -t ${config.fsType} "${config.device}" "${rootMountPoint}${config.mountpoint}" \
|
||||
${lib.concatMapStringsSep " " (opt: "-o ${opt}") config.mountOptions} \
|
||||
-o X-mount.mkdir
|
||||
fi
|
||||
'';
|
||||
};
|
||||
};
|
||||
_unmount = diskoLib.mkUnmountOption {
|
||||
inherit config options;
|
||||
|
||||
@@ -91,14 +91,12 @@
|
||||
updateOptions = builtins.removeAttrs createOptions onetimeProperties;
|
||||
in
|
||||
''
|
||||
if ! zfs get type "${config._name}" >/dev/null 2>&1; then
|
||||
if ! zfs get type ${config._name} >/dev/null 2>&1; then
|
||||
${
|
||||
if config._createFilesystem then
|
||||
''
|
||||
zfs create -up "${config._name}" \
|
||||
${lib.concatStringsSep " " (
|
||||
lib.mapAttrsToList (n: v: "-o ${n}=${lib.escapeShellArg v}") (createOptions)
|
||||
)}
|
||||
zfs create -up ${config._name} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
|
||||
''
|
||||
else
|
||||
''
|
||||
@@ -109,8 +107,8 @@
|
||||
${lib.optionalString (updateOptions != { }) ''
|
||||
else
|
||||
zfs set -u ${
|
||||
lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${lib.escapeShellArg v}") updateOptions)
|
||||
} "${config._name}"
|
||||
lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)
|
||||
} ${config._name}
|
||||
''}
|
||||
fi
|
||||
'';
|
||||
|
||||
@@ -63,11 +63,7 @@
|
||||
default = ''
|
||||
if ! zfs get type "${config._parent.name}/${config.name}" >/dev/null 2>&1; then
|
||||
zfs create "${config._parent.name}/${config.name}" \
|
||||
${
|
||||
lib.concatStringsSep " " (
|
||||
lib.mapAttrsToList (n: v: "-o ${n}=${lib.escapeShellArg v}") config.options
|
||||
)
|
||||
} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||
-V ${config.size} ${toString (builtins.map lib.escapeShellArg config.extraArgs)}
|
||||
zvol_wait
|
||||
partprobe "/dev/zvol/${config._parent.name}/${config.name}"
|
||||
|
||||
+2
-10
@@ -377,16 +377,8 @@ in
|
||||
else
|
||||
""
|
||||
} \
|
||||
${
|
||||
lib.concatStringsSep " " (
|
||||
lib.mapAttrsToList (n: v: "-o ${n}=${lib.escapeShellArg v}") config.options
|
||||
)
|
||||
} \
|
||||
${
|
||||
lib.concatStringsSep " " (
|
||||
lib.mapAttrsToList (n: v: "-O ${n}=${lib.escapeShellArg v}") config.rootFsOptions
|
||||
)
|
||||
} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-O ${n}=${v}") config.rootFsOptions)} \
|
||||
''${topology:+ $topology}
|
||||
if [[ $(zfs get -H mounted "${config.name}" | cut -f3) == "yes" ]]; then
|
||||
zfs unmount "${config.name}"
|
||||
|
||||
+2
-139
@@ -1,9 +1,9 @@
|
||||
{
|
||||
lib,
|
||||
writeShellApplication,
|
||||
bash,
|
||||
coreutils,
|
||||
git,
|
||||
gh,
|
||||
nix-fast-build,
|
||||
}:
|
||||
writeShellApplication {
|
||||
@@ -11,145 +11,8 @@ writeShellApplication {
|
||||
runtimeInputs = [
|
||||
bash
|
||||
git
|
||||
gh
|
||||
coreutils
|
||||
nix-fast-build
|
||||
];
|
||||
text = ''
|
||||
set -x
|
||||
|
||||
version=''${1:-}
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "USAGE: nix run .#create-release -- <version>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we're running from the root of the repository
|
||||
if [[ ! -f "flake.nix" || ! -f "version.nix" ]]; then
|
||||
echo "This script must be run from the root of the repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the version matches the semver pattern (without suffixes)
|
||||
semver_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
||||
if [[ ! "$version" =~ $semver_regex ]]; then
|
||||
echo "Version must match the semver pattern (e.g., 1.0.0, 2.3.4)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(git symbolic-ref --short HEAD)" != "master" ]]; then
|
||||
echo "must be on master branch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure there are no uncommitted or unpushed changes
|
||||
uncommitted_changes=$(git diff --compact-summary)
|
||||
if [[ -n "$uncommitted_changes" ]]; then
|
||||
echo -e "There are uncommitted changes, exiting:\n''${uncommitted_changes}" >&2
|
||||
exit 1
|
||||
fi
|
||||
git pull https://github.com/nix-community/disko master
|
||||
unpushed_commits=$(git log --format=oneline origin/master..master)
|
||||
if [[ "$unpushed_commits" != "" ]]; then
|
||||
echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
branch_name="release/v$version"
|
||||
|
||||
# Check if branch already exists
|
||||
if git show-ref --verify --quiet "refs/heads/$branch_name"; then
|
||||
echo "Branch $branch_name already exists locally, please delete it first" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if tag already exists (locally or remotely)
|
||||
if git show-ref --verify --quiet "refs/tags/v$version" || git ls-remote --tags origin "v$version" | grep -q .; then
|
||||
echo "Tag v$version already exists, aborting" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Create release branch
|
||||
git checkout -b "$branch_name"
|
||||
|
||||
# Update the version file
|
||||
cat > version.nix <<EOF
|
||||
{
|
||||
version = "$version";
|
||||
released = true;
|
||||
}
|
||||
EOF
|
||||
|
||||
# Commit the release version bump
|
||||
git commit -am "release: v$version"
|
||||
|
||||
# Push branch and create PR
|
||||
git push -u origin "$branch_name"
|
||||
pr_url=$(gh pr create --title "release: v$version" --body "Release v$version" --base master)
|
||||
echo "Created PR: $pr_url"
|
||||
|
||||
# Add to merge queue
|
||||
gh pr merge --merge --auto "$pr_url"
|
||||
echo "PR added to merge queue, waiting for merge..."
|
||||
|
||||
# Wait for PR to be merged
|
||||
while true; do
|
||||
state=$(gh pr view "$pr_url" --json state --jq '.state')
|
||||
if [[ "$state" == "MERGED" ]]; then
|
||||
echo "PR merged!"
|
||||
break
|
||||
elif [[ "$state" == "CLOSED" ]]; then
|
||||
echo "PR was closed without merging, aborting release" >&2
|
||||
git checkout master
|
||||
git branch -D "$branch_name"
|
||||
exit 1
|
||||
fi
|
||||
echo "Waiting for PR to merge (current state: $state)..."
|
||||
sleep 10
|
||||
done
|
||||
|
||||
# Switch back to master and pull the merged commit
|
||||
git checkout master
|
||||
git pull origin master
|
||||
|
||||
# Delete the local release branch
|
||||
git branch -D "$branch_name"
|
||||
|
||||
# Tag the release and push tags
|
||||
git tag -a "v$version" -m "release: v$version"
|
||||
git tag -d "latest" 2>/dev/null || true
|
||||
git tag -a "latest" -m "release: v$version"
|
||||
git push origin "v$version"
|
||||
git push --force origin latest
|
||||
|
||||
# Create follow-up branch to reset released flag
|
||||
followup_branch="release/v$version-followup"
|
||||
git checkout -b "$followup_branch"
|
||||
|
||||
cat > version.nix <<EOF
|
||||
{
|
||||
version = "$version";
|
||||
released = false;
|
||||
}
|
||||
EOF
|
||||
git commit -am "release: reset released flag"
|
||||
|
||||
git push -u origin "$followup_branch"
|
||||
followup_pr_url=$(gh pr create --title "release: reset released flag after v$version" --body "Reset released flag after v$version release" --base master)
|
||||
echo "Created follow-up PR: $followup_pr_url"
|
||||
gh pr merge --merge --auto "$followup_pr_url"
|
||||
|
||||
# Switch back to master
|
||||
git checkout master
|
||||
|
||||
# Create a draft GitHub release with auto-generated notes
|
||||
release_url=$(gh release create "v$version" --draft --generate-notes --verify-tag)
|
||||
edit_url=''${release_url/\/tag\//\/edit\/}
|
||||
|
||||
echo
|
||||
echo "Release v$version complete!"
|
||||
echo "Edit and publish the draft release:"
|
||||
echo
|
||||
echo " $edit_url"
|
||||
'';
|
||||
text = lib.readFile ./create-release.sh;
|
||||
}
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
# Don't run directly! Instead, use
|
||||
# nix run .#create-release
|
||||
|
||||
version=${1:-}
|
||||
if [[ -z "$version" ]]; then
|
||||
echo "USAGE: nix run .#create-release -- <version>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if we're running from the root of the repository
|
||||
if [[ ! -f "flake.nix" || ! -f "version.nix" ]]; then
|
||||
echo "This script must be run from the root of the repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the version matches the semver pattern (without suffixes)
|
||||
semver_regex="^([0-9]+)\.([0-9]+)\.([0-9]+)$"
|
||||
if [[ ! "$version" =~ $semver_regex ]]; then
|
||||
echo "Version must match the semver pattern (e.g., 1.0.0, 2.3.4)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$(git symbolic-ref --short HEAD)" != "master" ]]; then
|
||||
echo "must be on master branch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ensure there are no uncommitted or unpushed changes
|
||||
uncommited_changes=$(git diff --compact-summary)
|
||||
if [[ -n "$uncommited_changes" ]]; then
|
||||
echo -e "There are uncommited changes, exiting:\n${uncommited_changes}" >&2
|
||||
exit 1
|
||||
fi
|
||||
git pull git@github.com:nix-community/disko master
|
||||
unpushed_commits=$(git log --format=oneline origin/master..master)
|
||||
if [[ "$unpushed_commits" != "" ]]; then
|
||||
echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Run all tests to ensure we don't release a broken version
|
||||
# Two workers are safe on systems with at least 16GB of RAM
|
||||
nix-fast-build --no-link -j 2 --eval-workers 2 --flake .#checks
|
||||
|
||||
# Update the version file
|
||||
cat > version.nix <<EOF
|
||||
{
|
||||
version = "$version";
|
||||
released = false;
|
||||
}
|
||||
EOF
|
||||
|
||||
# Commit and tag the release
|
||||
git commit -am "release: v$version"
|
||||
git tag -a "v$version" -m "release: v$version"
|
||||
git tag -d "latest"
|
||||
git tag -a "latest" -m "release: v$version"
|
||||
|
||||
# a revsion suffix when run from the tagged release commit
|
||||
echo "{ version = \"$version\"; released = false; }" > version.nix
|
||||
git commit -am "release: reset released flag"
|
||||
|
||||
echo "Release was prepared successfully!"
|
||||
echo "To push the release, run the following command:"
|
||||
echo
|
||||
echo " git push origin master v$version && git push --force origin latest"
|
||||
echo
|
||||
echo "After that, create a release on GitHub:"
|
||||
echo
|
||||
echo " https://github.com/nix-community/disko/releases/new"
|
||||
+5
-8
@@ -17,7 +17,7 @@ diskoLib.testLib.makeDiskoTest {
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
kernelPackages = pkgs.linuxPackages_testing;
|
||||
supportedFilesystems = [ "bcachefs" ];
|
||||
};
|
||||
};
|
||||
@@ -39,9 +39,6 @@ diskoLib.testLib.makeDiskoTest {
|
||||
machine.succeed("lsblk >&2");
|
||||
machine.succeed("lsblk -f >&2");
|
||||
machine.succeed("mount >&2");
|
||||
# We need to manually unlock /dev/vda2 for some reason
|
||||
# even though it should already get unlocked by bootCommands
|
||||
machine.succeed(r'printf "secretsecret" | bcachefs unlock -k session /dev/vda2 >&2');
|
||||
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||
machine.succeed("findmnt --json >&2");
|
||||
@@ -56,10 +53,10 @@ diskoLib.testLib.makeDiskoTest {
|
||||
# Verify device membership and labels.
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
||||
machine.succeed(r"bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
||||
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
||||
|
||||
# Verify format arguments.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
version = "1.13.0";
|
||||
version = "1.12.0";
|
||||
released = false;
|
||||
}
|
||||
Reference in new issue
Block a user