This commit is contained in:
2025-08-26 18:33:56 +02:00
parent 4b06060222
commit 6e5dea6b65
9 changed files with 211 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2025 vm Copyright (c) 2025 kalle
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including associated documentation files (the "Software"), to deal in the Software without restriction, including

View File

@@ -1,2 +1,2 @@
# first # vm1

90
configuration.nix Normal file
View File

@@ -0,0 +1,90 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
{
imports = [ ./hw.nix ];
# boot.loader.grub.device = "/dev/vda";
# fileSystems."/" = {
# device = "/dev/vda1";
# fsType = "ext4";
# };
# network and proxy
networking.hostName = "minimal";
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/Stockholm";
# Select internationalisation properties.
i18n.defaultLocale = "sv_SE.UTF-8";
console = {
font = "Lat2-Terminus16";
keyMap = "sv-latin1";
};
# Define a user account. Don't forget to set a password with passwd.
security.sudo.wheelNeedsPassword = false;
programs.zsh.enable = true;
users.mutableUsers = true;
users.users.kalle = {
isNormalUser = true;
initialHashedPassword = "$6$92TJx1rnVZ8ZBWGk$.0CUy9wLNbfNdmkwhnQCOomFiy.oJA2bSzLOixoQS3UyV/BITD55IhEVfr05VUVJtjcUoVIE1We99qEAWAbkE/";
shell = pkgs.zsh;
extraGroups = [ "wheel" "docker" "networkmanager" "video" "audio" ]; # Enable sudo for the user.
packages = with pkgs; [
# common sense
zsh
tmux
fzf
fzf-zsh
bat
fd
];
};
# system packages
environment.systemPackages = with pkgs; [
# basic stuff
vim
btrfs-progs
# net
wireguard-tools
inetutils
wget
mosh
rsync
git
];
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "25.05"; # Did you read the comment?
}

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1754800730,
"narHash": "sha256-HfVZCXic9XLBgybP0318ym3cDnGwBs/+H5MgxFVYF4I=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "641d909c4a7538f1539da9240dedb1755c907e40",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

21
flake.nix Normal file
View File

@@ -0,0 +1,21 @@
# flake.nix
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
test = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./configuration.nix
];
};
in {
# Use `flake-config#test` with:
# nixos-rebuild --flake .#test build-vm
nixosConfigurations.test = test;
# Optional: expose VM script for `nix run .#vms.test`
vms.test = test.config.system.build.vm;
};
}

16
hw.nix Normal file
View File

@@ -0,0 +1,16 @@
{ lib, ... }:
{
# Let the image format own the root FS mapping
fileSystems."/" = lib.mkForce {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
# Make the image self-booting under libvirt
# virtualisation.useBootLoader = true;
boot.loader.grub.device = "/dev/vda";
# Optional: auto-grow root at first boot
boot.growPartition = true;
}

1
img_path Normal file
View File

@@ -0,0 +1 @@
/nix/store/9n7ck8byffxn8p9bw6cjxbpmqwjgdgji-nixos-disk-image/nixos.img

18
pull.sh Executable file
View File

@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Define the branch name
BRANCH_NAME="dev"
if [ ! $(git rev-parse --abbrev-ref HEAD) == $BRANCH_NAME ]; then
# Fetch the latest changes from the remote
git fetch origin
# If the branch exists, just switch to it
git switch $BRANCH_NAME || (git switch -c $BRANCH_NAME && git push -u origin $BRANCH_NAME)
fi
# get the latest changes
git pull origin $BRANCH_NAME --ff-only

36
push.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
# Define the branch name
BRANCH_NAME=dev
# Check if the branch exists locally
if git rev-parse --verify $BRANCH_NAME > /dev/null 2>&1; then
# Get commit message
# message=$(git diff | ~/scripts/shelly 'write a short git commit message for this diff')
message="$(date --iso-8601=seconds)"
echo $message
# Add and commit changes
git add .
git commit -m "$message"
# Pull the latest changes from the main branch to ensure we're up to date
git pull origin main
# Push the changes to the remote branch named dev_$(hostname)
git push origin $BRANCH_NAME
# Merge to main
git switch main
git merge dev
git commit
git push
# Switch to the branch
git switch $BRANCH_NAME
else
echo "Branch $BRANCH_NAME does not exist locally!"
exit 1
fi