Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyinstarlight committed Feb 27, 2024
0 parents commit a012ca0
Show file tree
Hide file tree
Showing 57 changed files with 98,229 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
commit-message:
prefix: "ci"
13 changes: 13 additions & 0 deletions .github/mergify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pull_request_rules:
- name: Auto-merge for dependency bump pull requests
conditions:
- or:
- author=dependabot[bot]
- author=github-actions[bot]
- label=dependencies

- check-success=Build
actions:
merge:
method: squash
delete_head_branch:
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
pull_request:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: DeterminateSystems/nix-installer-action@v9

- uses: cachix/cachix-action@v14
with:
name: cosmic
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- run: nix -vL build --show-trace .#vm
40 changes: 40 additions & 0 deletions .github/workflows/cosmic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Cosmic

on:
schedule:
- cron: '0 23 * * *'
workflow_dispatch:

jobs:
update:
name: Cosmic Update
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4

- uses: DeterminateSystems/nix-installer-action@v9

- run: nix -vL run --show-trace .#update

- id: create-pr
uses: peter-evans/create-pull-request@v6
with:
branch: update_cosmic_action
delete-branch: true
committer: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
commit-message: 'pkgs: update cosmic'
title: 'pkgs: update cosmic'
labels: 'dependencies'
body: |
Automated bump of Cosmic packages
- uses: benc-uk/workflow-dispatch@v121
if: ${{ contains(fromJSON('["created", "updated"]'), steps.create-pr.outputs.pull-request-operation) }}
with:
workflow: ci.yml
ref: refs/heads/update_cosmic_action
32 changes: 32 additions & 0 deletions .github/workflows/flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Flake

on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:

jobs:
update:
name: Flake Update
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4

- uses: DeterminateSystems/nix-installer-action@v9

- id: update-flake-lock
uses: DeterminateSystems/update-flake-lock@v20
with:
commit-msg: 'flake: update inputs'
pr-title: 'flake: update inputs'
pr-labels: 'dependencies'

- uses: benc-uk/workflow-dispatch@v121
if: ${{ contains(fromJSON('["created", "updated"]'), steps.update-flake-lock.outputs.pull-request-operation) }}
with:
workflow: ci.yml
ref: refs/heads/update_flake_lock_action
21 changes: 21 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ system ? builtins.currentSystem, ... }:

let
self = (import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${lock.nodes.${lock.root}.inputs.flake-compat}.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{
# hack to skip fetchGit when evaluating impurely and get original paths
src = {
outPath = ./.;
};
}
).defaultNix;
in

self.legacyPackages.${system} // self.packages.${system}
109 changes: 109 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

122 changes: 122 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
inputs = {
# TODO: switch to `github:NixOS/nixpkgs/nixos-unstable` once NixOS/nixpkgs#279009 is merged
#nixpkgs.url = "github:lilyinstarlight/nixpkgs/tmp/virgl";
nixpkgs.url = "/home/lily/src/nixpkgs";

# TODO: switch to `github:Mic92/nix-update` once Mic92/nix-update#227 and Mic92/nix-update#228 are merged
nix-update = {
url = "github:lilyinstarlight/nix-update/tmp/fixed";
inputs.nixpkgs.follows = "nixpkgs";
};

flake-compat = {
url = "github:nix-community/flake-compat";
flake = false;
};
};

outputs = { self, nixpkgs, nix-update, ... }: let
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
in {
lib = {
packagesFor = pkgs: import ./pkgs { inherit pkgs; };
};

packages = forAllSystems (system: self.lib.packagesFor nixpkgs.legacyPackages.${system});

overlays = {
default = final: prev: self.lib.packagesFor prev;
};

nixosModules = {
default = import ./nixos { inherit (nixpkgs) lib; cosmicOverlay = self.overlays.default; };
};

legacyPackages = forAllSystems (system: let pkgs = nixpkgs.legacyPackages.${system}; in {
update = pkgs.writeShellApplication {
name = "cosmic-update";

runtimeInputs = [
pkgs.coreutils
nix-update.packages.${system}.default
];

text = ''
for pkg in pkgs/*; do
if ! [ -f "$pkg/package.nix" ]; then
continue
fi
attr="$(basename "$pkg")"
if [ "$attr" = wrapCosmicAppsHook ]; then
continue
fi
nix-update --commit --version branch=HEAD "$attr"
done
'';
};

vm = (nixpkgs.lib.nixosSystem {
modules = [
({ lib, pkgs, modulesPath, ... }: {
imports = [
self.nixosModules.default

"${toString modulesPath}/virtualisation/qemu-vm.nix"
];

services.xserver.desktopManager.cosmic.enable = true;
services.xserver.displayManager.cosmic-greeter.enable = true;

environment.systemPackages = [ pkgs.drm_info ];

boot.kernelParams = [ "quiet" "udev.log_level=3" ];
boot.initrd.kernelModules = [ "bochs" ];

boot.initrd.verbose = false;

boot.initrd.systemd.enable = true;

boot.loader.systemd-boot.enable = true;
boot.loader.timeout = 0;

boot.plymouth.enable = true;
boot.plymouth.theme = "nixos-bgrt";
boot.plymouth.themePackages = [ pkgs.nixos-bgrt-plymouth ];

services.openssh = {
enable = true;
settings.PermitRootLogin = "yes";
};

documentation.nixos.enable = false;

users.mutableUsers = false;
users.users.root.password = "meow";
users.users.user = {
isNormalUser = true;
password = "meow";
};

virtualisation.useBootLoader = true;
virtualisation.useEFIBoot = true;
virtualisation.mountHostNixStore = true;

virtualisation.memorySize = 4096;

virtualisation.forwardPorts = [
{ from = "host"; host.port = 2222; guest.port = 22; }
];

nixpkgs.hostPlatform = system;

system.stateVersion = lib.trivial.release;
})
];
}).config.system.build.vm;
});
};
}
20 changes: 20 additions & 0 deletions license
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2024, Lily Foster <[email protected]>

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 without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit a012ca0

Please sign in to comment.