Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
dszakallas committed Oct 19, 2024
1 parent b7c59d0 commit 10cab01
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 106 deletions.
42 changes: 42 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended",
":automergeBranch",
":disableRateLimiting",
":dependencyDashboard",
":semanticCommits",
":skipStatusChecks",
":timezone(Europe/Prague)"
],
"commitMessageTopic": "{{depName}}",
"commitMessageExtra": "to {{newVersion}}",
"commitMessageSuffix": "",
"dependencyDashboardTitle": "Renovate Dashboard 🤖",
"suppressNotifications": ["prEditedNotification", "prIgnoreNotification"],
"ignorePaths": ["**/*.sops.*", "**/*.sec.*"],
"packageRules": [
// labels
{
"matchUpdateTypes": ["major"],
"labels": ["type/major"]
},
{
"matchUpdateTypes": ["minor"],
"labels": ["type/minor"]
},
{
"matchUpdateTypes": ["patch"],
"labels": ["type/patch"]
},
// automerge
{
"description": ["Auto-merge GitHub Actions for minor and patch"],
"matchManagers": ["github-actions"],
"matchDatasources": ["github-tags"],
"automerge": true,
"automergeType": "branch",
"matchUpdateTypes": ["minor", "patch"]
}
]
}
16 changes: 16 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on: # yamllint disable-line rule:truthy
push:
branches:
- '**'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
- uses: cachix/cachix-action@v15
with:
name: devenv
- run: nix profile install nixpkgs#devenv
- run: devenv test
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Devenv
.devenv*
devenv.local.nix

# direnv
.direnv

# pre-commit
.pre-commit-config.yaml
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Structure:

```
├── hosts # host configurations
├── lib # library functions
├── modules
│   ├── darwin # reusable modules for macOS
│   └── home # reusable modules for home manager
Expand Down
116 changes: 116 additions & 0 deletions devenv.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"nodes": {
"devenv": {
"locked": {
"dir": "src/modules",
"lastModified": 1729277673,
"owner": "cachix",
"repo": "devenv",
"rev": "3c3ab087b53d3e4699a43018ac71b5e1091ed73d",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1729265718,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ccc0c2126893dd20963580b6478d1a10a4512185",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1729181673,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "4eb33fe664af7b41a4c446f87d20c9a0a6321fa3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1729104314,
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "3c3e88f0f544d6bb54329832616af7eb971b6be6",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
}
},
"root": "root",
"version": 7
}
4 changes: 4 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ ... }: {
languages.nix.enable = true;
pre-commit.hooks.nixfmt-classic.enable = true;
}
3 changes: 3 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
64 changes: 34 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,47 @@ rec {

nixConfig = {
extra-experimental-features = [ "nix-command" "flakes" ];
extra-substituters = [ "https://nix-community.cachix.org" "https://devenv.cachix.org" ];
extra-substituters =
[ "https://nix-community.cachix.org" "https://devenv.cachix.org" ];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
];
};

outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager, davids-dotfiles-private, poetry2nix, ... }:
let
inherit (nixpkgs) lib;
subDirs = d: lib.foldlAttrs (a: k: v: a // (if v == "directory" then {${k} = d + "/${k}";} else {})) {} (builtins.readDir d);
davids-dotfiles = {
darwinModules = subDirs ./modules/darwin;
homeModules = subDirs ./modules/home;
};
mkDarwin = {host, arch, ...}: nix-darwin.lib.darwinSystem rec {
system = "${arch}-darwin";
specialArgs = {
inherit self home-manager davids-dotfiles davids-dotfiles-private poetry2nix system nixConfig;
};
modules = [
home-manager.darwinModules.home-manager
./hosts/${host}
{home-manager = {extraSpecialArgs = specialArgs;};}
];
};
in
{
darwinConfigurations = {
Jellyfish = mkDarwin {
host = "Jellyfish";
arch = "aarch64";
outputs = inputs@{ self, nix-darwin, nixpkgs, home-manager
, davids-dotfiles-private, poetry2nix, ... }:
let
davids-dotfiles = rec {
lib = import ./lib { inherit (nixpkgs) lib; };
darwinModules = lib.subDirs ./modules/darwin;
homeModules = lib.subDirs ./modules/home;
};
"dszakallas--Clownfish" = mkDarwin {
host = "dszakallas--Clownfish";
arch = "aarch64";
mkDarwin = { host, arch, ... }:
nix-darwin.lib.darwinSystem rec {
system = "${arch}-darwin";
specialArgs = let
hostPlatform = nixpkgs.legacyPackages.${system}.stdenv.hostPlatform;
in {
inherit self home-manager hostPlatform davids-dotfiles
davids-dotfiles-private poetry2nix system nixConfig;
};
modules = [
home-manager.darwinModules.home-manager
./hosts/${host}
{ home-manager = { extraSpecialArgs = specialArgs; }; }
];
};
in {
darwinConfigurations = {
Jellyfish = mkDarwin {
host = "Jellyfish";
arch = "aarch64";
};
"dszakallas--Clownfish" = mkDarwin {
host = "dszakallas--Clownfish";
arch = "aarch64";
};
};
};
};
}
12 changes: 4 additions & 8 deletions hosts/dszakallas--Clownfish/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{ self, davids-dotfiles, ... }:
let
myUsername = "dszakallas";
in
{
imports = [
davids-dotfiles.darwinModules.default
"${self}/users/${myUsername}"
];
let myUsername = "dszakallas";
in {
imports =
[ davids-dotfiles.darwinModules.default "${self}/users/${myUsername}" ];

nix.settings.trusted-users = [ "root" myUsername ];
}
12 changes: 4 additions & 8 deletions hosts/jellyfish/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{ self, davids-dotfiles, ... }:
let
myUsername = "davidszakallas";
in
{
imports = [
davids-dotfiles.darwinModules.default
"${self}/users/${myUsername}"
];
let myUsername = "davidszakallas";
in {
imports =
[ davids-dotfiles.darwinModules.default "${self}/users/${myUsername}" ];

nix.settings.trusted-users = [ "root" myUsername ];
}
8 changes: 8 additions & 0 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ lib, ... }:
with lib; {
# List immediate subdirectories of a directory
subDirs = d:
foldlAttrs
(a: k: v: a // (if v == "directory" then { ${k} = d + "/${k}"; } else { }))
{ } (builtins.readDir d);
}
5 changes: 2 additions & 3 deletions modules/darwin/default/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Shared configuration across my darwins.
{ self, pkgs, system, nixConfig, ... }:
{
{ self, pkgs, system, nixConfig, ... }: {
environment.systemPackages = with pkgs; [ curl vim git ];

environment.shells = with pkgs; [ bash zsh ];
Expand All @@ -9,7 +8,7 @@

# Create /etc/zshrc that loads the nix-darwin environment.
programs.zsh = {
enable = true; # default shell on catalina
enable = true; # default shell on catalina
shellInit = ''
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{ pkgs, config, system, ... }:
with pkgs; with lib;
let
brew = config.davids.brew;
in
{
with pkgs;
with lib;
let brew = config.davids.brew;
in {
options = with types; {
davids.brew = {
enable = mkEnableOption "Homebrew integration";
Expand Down
Loading

0 comments on commit 10cab01

Please sign in to comment.