Compare commits

..

22 commits

Author SHA1 Message Date
Dusty Pomerleau d2b524bc50 fix(darwin): correct typo during user creation (#36)
The darwin template was failing for me, until I changed user creation to `users.users.${username}`.

Co-authored-by: Dusty Pomerleau <dustypomerleau@users.noreply.github.com>
Reviewed-on: auxolotl/templates#36
Co-authored-by: Dusty Pomerleau <dustypomerleau@noreply.git.auxolotl.org>
Co-committed-by: Dusty Pomerleau <dustypomerleau@noreply.git.auxolotl.org>
2024-08-11 13:05:38 +00:00
sugar🍬🍭🏳️‍⚧️ dcb9bc3396 fix: update flake url in readme (#35)
Reviewed-on: auxolotl/templates#35
Reviewed-by: Skyler Grey <minion@clicks.codes>
Co-authored-by: sugar <sugar@sylveon.social>
Co-committed-by: sugar <sugar@sylveon.social>
2024-07-24 20:13:40 +00:00
Raphael Das Gupta 3fda15c3f9 refactor(system): move system.stateVersion comment out of nix.* (#34)
Move comment about `system.stateVersion` out of attrset `nix`, as it has nothing to do with the `nix.*` options, but belongs with the `system.stateVersion` option below (after) attrset `nix`.

(This is also where this comment originally was, until it was moved in [47129554e4](47129554e4).)

Reviewed-on: auxolotl/templates#34
Reviewed-by: Skyler Grey <minion@clicks.codes>
Co-authored-by: Raphael Borun Das Gupta <git@raphael.dasgupta.ch>
Co-committed-by: Raphael Borun Das Gupta <git@raphael.dasgupta.ch>
2024-07-18 20:03:04 +00:00
Samuel Shuert 821048587f
Merge pull request #31 from auxolotl/chore/inputs
chore: change to cleanup flake files
2024-06-12 18:16:24 -04:00
isabel roses 6d9f867465
chore: ignore some inputs 2024-05-18 09:29:07 +01:00
isabel roses 03a8f01dfe
chore: change to nixos/nixpkgs 2024-05-18 09:28:57 +01:00
Samuel Shuert 76519a32df
Merge pull request #30 from ztr-pen/patch-1
fix: README commands missing flake subcommand
2024-05-17 12:04:31 -04:00
ztr-pen bcc0fbbfcc
Update README.md - incorrect commands
Update commands to include correct flake commands for Darwin, Nixos and Home-Manager
2024-05-17 16:59:34 +10:00
Samuel Shuert a3ca38e31c
fix: spell experimental feature flake as flakes 2024-05-16 20:19:15 -04:00
Samuel Shuert 84216867bd
Update README.md to rename FreshwaterOS to Auxolotl 2024-05-16 20:17:00 -04:00
isabel roses fdbefeff2a
Merge pull request #27 from Sigmanificient/c 2024-05-14 20:24:13 +00:00
Samuel Shuert cfd424d324
Fix: Update home-manager
Forgot to save >~<
2024-05-11 16:31:56 -04:00
Samuel Shuert e83ad899f6
Fix: Update nixpkgs url for new roadmap 2024-05-11 16:30:01 -04:00
isabel roses 78374d6350
Merge pull request #28 from auxolotl/remove-system-from-nixosSystem 2024-05-07 21:58:46 +00:00
Sigmanificient d981bc409e fix(c): simplify the template config files 2024-05-07 23:48:25 +02:00
NotAShelf 72b9616f87
fix(system): remove ambigious system from nixosSystem 2024-05-07 14:03:53 +03:00
Sigmanificient 57769ca9ed refactor(c): improve flake structure
Co-authored-by: isabelroses <isabel@isabelroses.com>
2024-05-07 00:54:12 +02:00
Sigmanificient e2607d77cc fix(c): fix flake output (devshell, apps) 2024-05-06 23:56:16 +02:00
Sigmanificient a95b46a6a0 style(c): apply nixfmt-rfc-style to flake 2024-05-06 23:52:47 +02:00
Sigmanificient c1524d5bd9 feat(c): add configuration files 2024-05-06 23:40:38 +02:00
Sigmanificient 30022cc914 feat(c): setup the flake 2024-05-06 23:40:26 +02:00
Sigmanificient aff83a7bf1 feat(c): add hello source 2024-05-06 23:40:01 +02:00
26 changed files with 194 additions and 471 deletions

View file

@ -3,7 +3,7 @@
</p>
<p align="center">
This is a template repository for getting started with your brand new FreshwaterOS system.
This is a template repository for getting started with your brand new Auxolotl system.
</p>
<p align="center">
@ -22,7 +22,7 @@ There are 3 main templates in this repository:
#### With Darwin (macOS)
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flake new -t github:auxolotl/templates#darwin NixFiles` in the terminal. This will setup the basic configuration for the system, this generate a configuration for you from the files located in the `darwin` directory.
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t git+https://git.auxolotl.org/auxolotl/templates#darwin NixFiles` in the terminal. This will setup the basic configuration for the system, this generate a configuration for you from the files located in the `darwin` directory.
2. The next step is to go into the `NixFiles` directory this can be achieved by running `cd NixFiles`.
3. Now we you need to read over the configuration files and make any changes that you see fit, some of these must include changing your username and hostname.
4. You now must rebuild this configuration we can do this with `nix run darwin -- switch --flake .#hostname` hostname should be substituted for your systems hostname.
@ -30,7 +30,7 @@ There are 3 main templates in this repository:
#### With NixOS
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flake new -t github:auxolotl/templates#system NixFiles`
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t git+https://git.auxolotl.org/auxolotl/templates#system NixFiles`
2. Move into your new system with `cd NixFiles`
3. Fill in your `hostName` in `flake.nix`
4. Run `nixos-generate-config --show-hardware-config > hardware-configuration.nix` to generate configuration based on your filesystems and drivers
@ -40,6 +40,6 @@ Congratulations, you are now using Aux!
#### With Home-manager
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flake new -t github:auxolotl/templates#home-manager NixFiles` to start
1. Run `nix --extra-experimental-features nix-command --extra-experimental-features flakes flake new -t git+https://git.auxolotl.org/auxolotl/templates#home-manager NixFiles` to start
2. Move into your new Nix system with `cd NixFiles`
3. Fill in your `username` in `flake.nix`

22
c/.editorconfig Normal file
View file

@ -0,0 +1,22 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 80
tab_width = 4
[{Makefile,*.mk}]
indent_style = tab
[*.nix]
indent_style = space
tab_width = 2
indent_size = 2
[*.lock]
indent_style = unset
insert_final_newline = unset

64
c/.gitignore vendored Normal file
View file

@ -0,0 +1,64 @@
# binaries
hello
# language support
compile_commands.json
.cache
# nix
.direnv
result*
repl-result-*
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

30
c/Makefile Normal file
View file

@ -0,0 +1,30 @@
CC ?= gcc
CFLAGS += -pedantic -Wall -Wextra -O2
OUT := hello
BINDIR ?= /usr/bin
SRC += main.c
OBJ := $(SRC:.c=.o)
.PHONY: all
all: $(OUT)
$(OUT): $(OBJ)
$(CC) -o $@ $<
.PHONY: clean
clean:
$(RM) $(OBJ)
.PHONY: fclean
fclean: clean
$(RM) -r $(OUT)
.PHONY: re
.NOTPARALLEL: re
re: fclean all
.PHONY: install
install:
install -D hello ${BINDIR}/hello --mode 0755

27
c/flake.nix Normal file
View file

@ -0,0 +1,27 @@
{
description = "Aux template for C project";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs =
{ nixpkgs, ... }:
let
forAllSystems =
function:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
system: function nixpkgs.legacyPackages.${system}
);
in
rec {
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell { inputsFrom = [ packages.${pkgs.system}.hello ]; };
});
packages = forAllSystems (pkgs: rec {
default = hello;
hello = pkgs.callPackage ./hello.nix { };
});
overlays.default = final: prev: { hello = prev.callPackage ./default.nix { }; };
};
}

7
c/hello.nix Normal file
View file

@ -0,0 +1,7 @@
{ stdenv }:
stdenv.mkDerivation {
name = "hello";
src = ./.;
env.BINDIR = "${placeholder "out"}/bin";
}

11
c/main.c Normal file
View file

@ -0,0 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char greet[] = "hello, world!\n";
int written = printf("%s", greet);
return written == (sizeof(greet) - 1)
? EXIT_SUCCESS : EXIT_FAILURE;
}

View file

@ -4,7 +4,7 @@
inputs = {
# nixpkgs is the input that we use for this flake the end section `nixpkgs-unstable` refers to the branch
# of nixpkgs that we want to use. This can be changed to any branch or commit hash.
nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
@ -23,13 +23,7 @@
};
outputs =
inputs@{
self,
nixpkgs,
darwin,
home-manager,
...
}:
inputs@{ darwin, home-manager, ... }:
# we can use the `let` and `in` syntax to define variables
# and use them in the rest of the expression
let
@ -82,7 +76,7 @@
};
};
# Here we can create our user
uses.users.${username} = {
users.users.${username} = {
home = "/Users/${username}";
};

View file

@ -1,7 +1,7 @@
{
description = "An empty devshell with direnv support";
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs =
{ nixpkgs, ... }:

View file

@ -1,7 +1,7 @@
{
description = "Templates for getting started with Aux";
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs =
{ self, nixpkgs }:
@ -34,10 +34,6 @@
path = ./direnv;
description = "An empty devshell with direnv support";
};
rust = {
path = ./rust;
description = "Rust specific template providing packaging, dev-shell & cross-compilation; based on fenix.";
};
};
formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
};

View file

@ -2,7 +2,7 @@
description = "A simple home-manager flake using Aux";
inputs = {
nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";

View file

@ -1,38 +0,0 @@
root = true
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.nix]
indent_style = space
indent_size = 2
insert_final_newline = false
[*.rs,Cargo.toml]
indent_size = 4
insert_final_newline = false
[*.md]
indent_size = 2
trim_trailing_whitespace = false
insert_final_newline = false
[*.{json,json5,yaml,yml,webmanifest}]
indent_style = space
indent_size = 2
[*.toml]
indent_style = unset
indent_size = 0
[*.lock]
indent_style = unset
insert_final_newline = unset
[Makefile]
indent_style = tab

2
rust/.gitignore vendored
View file

@ -1,2 +0,0 @@
result
target/

6
rust/Cargo.lock generated
View file

@ -1,6 +0,0 @@
# placeholder for the real Cargo.lock,
# so that evaluating the flake does not fail due to missing files,
# before using `cargo init` to create the 'real' files
version = 3
[[package]]

View file

@ -1,9 +0,0 @@
# placeholder for the real Cargo.toml,
# so that evaluating the flake does not fail due to missing files,
# before using `cargo init` to create the 'real' files
[package]
name = "bin"
version = "0.1.0"
[profile.release]
overflow-checks = true

View file

@ -1,9 +0,0 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).defaultNix

View file

@ -1,164 +0,0 @@
{
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
nixpkgs.url = "github:NixOs/nixpkgs/nixos-unstable";
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
fenix,
...
}@inputs:
let
cargoMeta = builtins.fromTOML (builtins.readFile ./Cargo.toml);
packageName = cargoMeta.package.name;
forSystems =
function:
nixpkgs.lib.genAttrs [ "x86_64-linux" ] (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (final: prev: { ${packageName} = self.packages.${system}.${packageName}; }) ];
};
fenixPkgs = fenix.packages.${pkgs.system};
fenixChannel = fenixPkgs.toolchainOf {
channel = "nightly";
date =
builtins.replaceStrings [ "nightly-" ] [ "" ]
(builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)).toolchain.channel;
sha256 = "sha256-SzEeSoO54GiBQ2kfANPhWrt0EDRxqEvhIbTt2uJt/TQ=";
};
toolchainFor =
pkgs:
with fenixPkgs;
combine [
minimal.cargo
minimal.rustc
targets.${pkgs.rust.lib.toRustTarget pkgs.stdenv.targetPlatform}.latest.rust-std
];
rustPlatformFor =
pkgs:
let
toolchain = toolchainFor pkgs;
in
pkgs.makeRustPlatform {
cargo = toolchain;
rustc = toolchain;
};
crossPackageFor =
pkgs:
let
rustPlatform = rustPlatformFor pkgs;
in
{
"${packageName}-cross-${pkgs.stdenv.hostPlatform.config}${
if pkgs.stdenv.hostPlatform.isStatic then "-static" else ""
}" = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") {
inherit cargoMeta rustPlatform;
flake-self = self;
};
};
in
function {
inherit
system
pkgs
fenixPkgs
fenixChannel
toolchainFor
rustPlatformFor
crossPackageFor
;
}
);
in
{
formatter = forSystems ({ pkgs, ... }: pkgs.alejandra);
checks = forSystems (
{ pkgs, fenixChannel, ... }:
{
rustfmt =
pkgs.runCommand "check-rustfmt"
{
nativeBuildInputs =
let
fenixRustToolchain = fenixChannel.withComponents [
"cargo"
"rustfmt-preview"
];
in
[ fenixRustToolchain ];
}
''
cd ${./.}
cargo fmt -- --check
touch $out
'';
}
);
packages = forSystems (
{
pkgs,
fenixChannel,
system,
crossPackageFor,
...
}:
{
${packageName} = pkgs.callPackage (./. + "/nix/packages/${packageName}.nix") {
inherit cargoMeta;
flake-self = self;
rustPlatform = pkgs.makeRustPlatform {
cargo = fenixChannel.toolchain;
rustc = fenixChannel.toolchain;
};
};
default = self.packages.${system}.${packageName};
}
// crossPackageFor pkgs.pkgsCross.musl64.pkgsStatic
// crossPackageFor pkgs.pkgsCross.musl32.pkgsStatic
// crossPackageFor pkgs.pkgsCross.aarch64-multiplatform-musl.pkgsStatic
// crossPackageFor pkgs.pkgsCross.armv7l-hf-multiplatform.pkgsStatic
// crossPackageFor pkgs.pkgsCross.mingwW64.pkgsStatic
);
devShells = forSystems (
{ pkgs, fenixChannel, ... }:
let
fenixRustToolchain = fenixChannel.withComponents [
"cargo"
"clippy-preview"
"rust-src"
"rustc"
"rustfmt-preview"
];
in
{
default = pkgs.callPackage (./. + "/nix/dev-shells/${packageName}.nix") {
inherit fenixRustToolchain cargoMeta;
};
ci = pkgs.callPackage (./nix/dev-shells/ci.nix) { inherit fenixRustToolchain cargoMeta; };
}
);
};
}

View file

@ -1,45 +0,0 @@
# move bin.nix files under nix/
# to the correct place
# for the new package name $packageName
# (i.e. $packageName.nix)
# delete this after running it
setup packageName:
mv nix/dev-shells/bin.nix "nix/dev-shells/{{ packageName }}.nix"
mv nix/packages/bin.nix "nix/packages/{{ packageName }}.nix"
rm Cargo.lock Cargo.toml
# pass --vcs none to disable addition to .gitignore
# (which would add the Cargo.lock to it)
cargo init --vcs none --lib --edition 2021 --name "{{ packageName }}"
# generate inital lockfile
cargo build
# make sure nix sees new *.nix files
git add .
build:
cargo build
build-release:
cargo build --release
run:
cargo run
run-release:
cargo run --release
format:
cargo fmt --check
eclint -exclude "{Cargo.lock,flake.lock}"
format-fix:
cargo fmt
eclint -exclude "{Cargo.lock,flake.lock}" -fix
lint:
cargo clippy
lint-fix:
cargo clippy --fix
reuse:
reuse lint

View file

@ -1,34 +0,0 @@
{
cargoMeta,
pkgs,
mkShell,
fenixRustToolchain,
bashInteractive,
cargo-edit,
reuse,
just,
eclint,
}:
mkShell {
inputsFrom = [ pkgs.${cargoMeta.package.name} ];
packages = [
fenixRustToolchain
bashInteractive
# for upgrading dependencies (i.e. versions in Cargo.toml)
cargo-edit
reuse
just
eclint
];
shellHook = ''
unset SOURCE_DATE_EPOCH
just --list --list-heading $'just <task>:\n'
'';
}

View file

@ -1,37 +0,0 @@
{
cargoMeta,
pkgs,
mkShell,
fenixRustToolchain,
bashInteractive,
reuse,
just,
eclint,
commitlint,
}:
mkShell {
inputsFrom = [ pkgs.${cargoMeta.package.name} ];
packages = [
fenixRustToolchain
bashInteractive
reuse
just
eclint
# nix develop ".#ci" --command --
# eclint
# -exclude "Cargo.lock"
# -exclude "flake.lock"
commitlint
# nix develop ".#ci" --command --
# commitlint
# --color false --verbose
# --from $(git rev-list --max-parents=0 HEAD | head -n 1)
# --to HEAD
];
}

View file

@ -1,36 +0,0 @@
{
lib,
flake-self,
cargoMeta,
rustPlatform,
}:
let
fs = lib.fileset;
sourceFiles = fs.unions [
(fs.maybeMissing ../../src)
(fs.maybeMissing ../../Cargo.toml)
(fs.maybeMissing ../../Cargo.lock)
];
in
rustPlatform.buildRustPackage {
inherit (cargoMeta.package) version;
pname = cargoMeta.package.name;
src = fs.toSource {
root = ../../.;
fileset = sourceFiles;
};
cargoLock.lockFile = ../../Cargo.lock;
VERGEN_IDEMPOTENT = "1";
VERGEN_GIT_SHA =
if flake-self ? "rev" then
flake-self.rev
else if flake-self ? "dirtyRev" then
flake-self.dirtyRev
else
lib.warn "no git rev available" "NO_GIT_REPO";
VERGEN_GIT_BRANCH = if flake-self ? "ref" then flake-self.ref else "";
VERGEN_GIT_COMMIT_TIMESTAMP = flake-self.lastModifiedDate;
}

View file

@ -1,4 +0,0 @@
[toolchain]
channel = "nightly-2023-12-21"
components = ["rust-analyzer", "rust-src"]
profile = "default"

View file

@ -1,27 +0,0 @@
edition = "2021"
version = "Two"
newline_style = "Unix"
format_generated_files = false
hard_tabs = true
tab_spaces = 4
max_width = 80
doc_comment_code_block_width = 80
comment_width = 80
error_on_line_overflow = true
error_on_unformatted = true
normalize_comments = true
normalize_doc_attributes = true
use_try_shorthand = true
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
reorder_impl_items = true
match_block_trailing_comma = true
use_field_init_shorthand = true

View file

@ -1,9 +0,0 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).shellNix

View file

@ -101,37 +101,27 @@
];
nix = {
registry.nixpkgs = {
from = {
id = "nixpkgs";
type = "indirect";
};
to = {
owner = "auxolotl";
repo = "nixpkgs";
type = "github";
};
};
gc.automatic = true;
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
};
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
# Most users should NEVER change this value after the initial install, for any reason,
# even if you've upgraded your system to a new NixOS release.
#
# This value does NOT affect the Nixpkgs version your packages and OS are pulled from,
# so changing it will NOT upgrade your system - see https://nixos.org/manual/nixos/stable/#sec-upgrading for how
# to actually do that.
#
# This value being lower than the current NixOS release does NOT mean your system is
# out of date, out of support, or vulnerable.
#
# Do NOT change this value unless you have manually inspected all the changes it would make to your configuration,
# and migrated your data accordingly.
#
# For more information, see `man configuration.nix` or https://nixos.org/manual/nixos/stable/options#opt-system.stateVersion .
system.stateVersion = "24.05"; # Did you read the comment?
}

View file

@ -1,7 +1,7 @@
{
description = "A simple system flake using some Aux defaults";
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixos-unstable";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
outputs =
inputs@{ nixpkgs, ... }:
@ -11,11 +11,13 @@
in
{
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
./configuration.nix
{ networking.hostName = hostName; }
{
networking.hostName = hostName;
nixpkgs.hostPlatform = system;
}
];
specialArgs = {