Skip to content

Commit

Permalink
fmt: add treefmt to use multiple formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
brckd committed Mar 29, 2024
1 parent f71b1c5 commit 1e6161e
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 122 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Dotfiles for NixOS using Flakes. Contains modules and configurations for NixOS,
## Using existing configurations

1. Make sure to have [NixOS](https://nixos.org/manual/nixos/stable/index.html#ch-installation),
[nix-on-droid](https://github.com/nix-community/nix-on-droid#try-it-out) or just
[Nix](https://nixos.org/download#download-nix) properly installed.
[nix-on-droid](https://github.com/nix-community/nix-on-droid#try-it-out) or just
[Nix](https://nixos.org/download#download-nix) properly installed.

2. [Enable Flakes](https://nixos.wiki/wiki/Flakes#Enable_flakes_temporarily) if you haven't already.

Expand Down
4 changes: 1 addition & 3 deletions configs/droid/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
pkgs,
...
}:

with builtins;
let
with builtins; let
hm-config = config.home-manager.config;
in {
system.stateVersion = "23.11";
Expand Down
88 changes: 22 additions & 66 deletions flake.lock

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

24 changes: 16 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.ez-configs.flakeModule
inputs.treefmt-nix.flakeModule
];

inherit systems;
Expand All @@ -38,8 +39,14 @@
};
};

perSystem = {pkgs, ...}: {
formatter = pkgs.alejandra;
perSystem = {...}: {
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
prettier.enable = true;
};
};
};

flake = {
Expand All @@ -66,7 +73,7 @@
};

inputs = {
# Loaders
# Systems
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

home-manager = {
Expand All @@ -80,6 +87,7 @@
inputs.home-manager.follows = "home-manager";
};

# Flake Framework
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
Expand All @@ -91,21 +99,21 @@
inputs.flake-parts.follows = "flake-parts";
};

# Meta
flake-compat.url = "github:edolstra/flake-compat";

alejandra = {
url = "github:kamadorueda/alejandra/3.0.0";
# Formatter
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flakeCompat.follows = "flake-compat";
};

# Scheming
stylix = {
url = "github:danth/stylix";
inputs.nixpkgs.follows = "nixpkgs";
};

# Packages
# Programs
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
Expand Down
2 changes: 1 addition & 1 deletion modules/home/ags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

```bash
home-manager switch --flake .
``````
```

2. Install type definitions.

Expand Down
18 changes: 12 additions & 6 deletions modules/home/ags/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ const entry = `${App.configDir}/src/index.ts`;
const main = `/tmp/ags/main.js`;

await Utils.execAsync([
"bun", "build", entry,
"--outfile", main,
"--external", "ressource://*",
"--external", "gi://*",
"--external", "file://*",
"bun",
"build",
entry,
"--outfile",
main,
"--external",
"ressource://*",
"--external",
"gi://*",
"--external",
"file://*",
]).catch(console.error);

await import(`file://${main}`)
await import(`file://${main}`);
16 changes: 8 additions & 8 deletions modules/home/ags/default.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
{
config,
lib,
pkgs,
pkgs,
...
}:
with lib; let
cfg = config.programs.ags;
colors = config.lib.stylix.colors;
colorNames = (map (n: "base${fixedWidthNumber 2 n}") (range 0 16));
colorNames = map (n: "base${fixedWidthNumber 2 n}") (range 0 16);
in {
config = mkIf cfg.enable {
programs.ags = {
configDir = ./.;
};
xdg.configFile."ags".recursive = true;
xdg.configFile."ags".recursive = true;

xdg.configFile."ags/src/style/colors.css".text =
concatMapStringsSep "\n"
(color: "@define-color ${color} ${colors.withHashtag.${color}};")
colorNames;
colorNames;

xdg.configFile."ags/src/assets/nixos-symbolic.svg".source = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/35ebbbf01c3119005ed180726c388a01d4d1100c/logo/white.svg";
hash = "sha256-Ed2l6i2wi/YTcWCq23bspH/t3RYp6AodykpXF1Zgccw=";
};
xdg.configFile."ags/src/assets/nixos-symbolic.svg".source = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/35ebbbf01c3119005ed180726c388a01d4d1100c/logo/white.svg";
hash = "sha256-Ed2l6i2wi/YTcWCq23bspH/t3RYp6AodykpXF1Zgccw=";
};
};
}
6 changes: 3 additions & 3 deletions modules/home/ags/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"peerDependencies": {
"typescript": "^5.0.0"
},
"scripts": {
"postinstall": "rm types; ln -s $HOME/.local/share/com.github.Aylur.ags/types types"
}
"scripts": {
"postinstall": "rm types; ln -s $HOME/.local/share/com.github.Aylur.ags/types types"
}
}
4 changes: 2 additions & 2 deletions modules/home/ags/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import Bar from "./widget/Bar";

App.addIcons(`${App.configDir}/src/assets`);
App.config({
windows: [Bar(0)],
style: `${App.configDir}/src/style/global.css`,
windows: [Bar(0)],
style: `${App.configDir}/src/style/global.css`,
});
48 changes: 26 additions & 22 deletions modules/home/ags/src/widget/Bar/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
export default (monitor = 0) => Widget.Window({
monitor,
name: `bar-${monitor}`,
anchor: ["top", "left", "right"],
exclusivity: "exclusive",
child: Widget.CenterBox({
startWidget: Widget.Box({
hexpand: true,
hpack: "start",
child: Widget.Icon("nixos-symbolic"),
}),
centerWidget: Widget.Box({
hpack: "center",
child: Widget.Label().poll(1000, self => self.label = Utils.exec("date")),
}),
endWidget: Widget.Box({
hexpand: true,
hpack: "end",
child: Widget.Icon("nixos-symbolic"),
}),
}),
});
export default (monitor = 0) =>
Widget.Window({
monitor,
name: `bar-${monitor}`,
anchor: ["top", "left", "right"],
exclusivity: "exclusive",
child: Widget.CenterBox({
startWidget: Widget.Box({
hexpand: true,
hpack: "start",
child: Widget.Icon("nixos-symbolic"),
}),
centerWidget: Widget.Box({
hpack: "center",
child: Widget.Label().poll(
1000,
(self) => (self.label = Utils.exec("date")),
),
}),
endWidget: Widget.Box({
hexpand: true,
hpack: "end",
child: Widget.Icon("nixos-symbolic"),
}),
}),
});
2 changes: 1 addition & 1 deletion modules/home/ags/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
"checkJs": true,
"checkJs": true,

// Bundler mode
"moduleResolution": "bundler",
Expand Down

0 comments on commit 1e6161e

Please sign in to comment.